Appium-Drivers-Windows


Appium has the ability to automate Windows PC Desktop apps. This driver relies on a project from Microsoft called WinAppDriver, which is an Appium-compatible WebDriver server for Windows Desktop apps (and more in the future). WinAppDriver is often abbreviated “WAD”. WAD is bundled with Appium and does not need to be installed separately.

Appium能够自动化Windows PC桌面apps.
这个dirver依靠Microsoft的一个叫WinAppDriver
这是一个Appium-compatible WebDriver server为Windows Desktop apps(未来有更多)
WinAppDriver通常缩写为“WAD”
WAD与Appium捆绑在一起,不需要单独安装

The Windows Driver supports testing of Universal Windows Platform (UWP) and Classic Windows (Win32) applications.

Windows Driver支持测试通用Windows Platform(UWP)
和Win32 applications.

In addition to the WAD repo, development of the Appium driver takes place at the appium-windows-driver repo.

除WAD repo外,
也可在 appium-windows-driver repo开发 Appium driver
Requirements and Support

In addition to Appium’s general requirements:

  • Windows PC with Windows 10 or upwin10以上
  • Ability to enter Administrator mode可以进入管理员模式
Usage

The way to start a session using the Windows driver is to include the platformName capability in your new session request, with the value Windows. Also, ensure that you set the deviceName capability to WindowsPC as well. Of course, you must also include an appropriate app capability, at a minimum (see below).

开始会话使用Windows driver应包含platformName capability在你的新会话请求中
并且值为Windows
此外确保你的deviceName capability也设置为WindowsPC
当然,你必须至少包括适当的app
Capabilities

The Windows driver supports a number of standard Appium capabilities. See below for how these should be used specifically with the Windows driver.

Windows driver支持多标准Appium功能
Setup

To test a Windows app, simply make sure you have turned developer mode on.

要测试Windows app,仅需确认你的开发者模式开启

When running Appium (whether Appium Desktop or from the command line), ensure that you have started the app / cmd prompt as an administrator.

运行Appium时(无论是Appium Desktop还是命令行),
确保是管理员启动app/cmd
Writing Tests for the Windows Driver
为Windows Driver写一个测试

You could begin by taking a look at some existing samples:

Java Samples
  1. Open the sample folder as an existing project in a Java IDE such as IntelliJ. For example: CalculatorTest 2. In the Java IDE build and run the test
在Java IDE中,打开示例文件夹作为现有项目
例如:CalculatorTest 2
在Java IDE建立和运行测试
C# Samples
  1. Pull and open CalculatorTest.sln under CalculatorTest 2. In Visual Studio 2015 with the test solution open build the test and select Test > Run > All Tests
拖出并打开CalculatorTest.sln在CalculatorTest下
在Visual Studio 2015带有的测试方案打开创建这个测试
并且选择Test > Run > All Tests
Javascript/node Samples

1.Using selenium-webdriver使用selenium-webdriver

Examples on selenium-appium样例放在selenium-appium上

selenium-webdriver-winappdriver-example

If you want to write tests from scratch, you can choose any programming language or tools supported by Appium/Selenium to write your test scripts. In the example below, we will author the test script in C# using Microsoft Visual Studio 2015.

如果你想从头开始编写测试,
你可以选择Appium/Selenium支持的编程语言和工具并写测试脚本
下面示例中:
我们将以C#用Microsoft Visual Studio 2015编写脚本
Create Test Project

1.Open Microsoft Visual Studio 2015打开VS2015
2.Create the test project and solution. I.e. select New Project > Templates > Visual C# > Test > Unit Test Project闯将项目
3.Once created, select Project > Manage NuGet Packages… > Browse and search for Appium.WebDriver浏览搜索 Appium.WebDriver
4.Install the Appium.WebDriver NuGet packages for the test project为项目安装Appium.WebDriver NuGet packages
5.Start writing your test (see sample code under [samples])开始编写你的测试(查看示例代码)

Universal Windows Platform App Testing

To test a UWP app, you can use any Selenium supported language and simply specify the Application Id for the app under test in the app capabilities entry. Below is an example of creating a test session for Windows Alarms & Clock app written in C#:

为测试UWP app,
你可以使用任何Selenium支持的语言
并且只需在app capabilities中加入指定被测Application Id
下面是一个样例关于创建测试会话为Windows Alarms&Clock app以C#编写的
// Launch the AlarmClock app
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App");
AlarmClockSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
// Control the AlarmClock app
AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click();
AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear();

When testing the application you authored yourself, you can find the Application Id in the generated AppX\vs.appxrecipe file under RegisteredUserNmodeAppID node. E.g. c24c8163-548e-4b84-a466-530178fc0580_scyf5npe3hv32!App

当测试你自己编写的application时,
你可以查找Application Id在...文件下
Classic Windows App Testing

To test a classic Windows app, you can also use any Selenium supported language and specify the full executable path for the app under test in the app capabilities entry. Below is an example of creating a test session for Windows Notepad app:

要测试一个经典Windows app,
你仍可以使用任何Selenium支持的语言
并且在app capabilities加入完整可执行路径
下面是一个关于为Windows Notepad app建立会话的样例
// Launch Notepad
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", @"C:\Windows\System32\notepad.exe");
NotepadSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
// Control the Notepad app
NotepadSession.FindElementByClassName("Edit").SendKeys("This is some text");
Starting a Session

As mentioned above, you should additionally use these capabilities to ensure you are getting a Windows App automation session:

如上所述,
你应该用这些功能来确保你的Windows App 是自动会话的

platformName: Windows deviceName: WindowsPC app: the appID of the Windows app for testing, or the path to the .exe file

Inspecting UI Elements

Microsoft Visual Studio 2015 by default includes Windows SDK that provides great tool to inspect the application you are testing. This tool allows you to see every UI element/node that you can query using Windows Application Driver. This inspect.exe tool can be found under the Windows SDK folder such as C:\Program Files (x86)\Windows Kits\10\bin\x86. The tool will show various element attributes. The table below shows you which Appium locator strategy you should use to find elements with the corresponding attributes.

Microsoft Visual Studio 2015通过默认包含的Windows SDK为检查你正在测试的pplication提供很大的帮助.
此工具允许你查看所有UI element/node你能询问使用的Windows Application Driver
工具的位置
LocatorStrategyMatched Attribute
accessibility idAutomationId
class nameClassName
nameName
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Aniona

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值