I've found blog posts on my site where I'm using the Selenium Web Testing Framework as far back as 2007! Today there's Selenium Drivers for every web browser including Microsoft Edge. You can write Selenium tests in nearly any language these days including Ruby, Python, Java, and C#.
我可以在自己的网站上找到博客帖子,这些博客帖子早在2007年就在使用Selenium Web测试框架! 如今,包括Microsoft Edge在内的每个Web浏览器都有Selenium驱动程序。 如今,您可以使用几乎任何语言(包括Ruby,Python,Java和C#)编写Selenium测试。
I'm a big Selenium fan. I like using it with systems like BrowserStack to automate across many different browser on many operating systems.
我是Selenium的忠实粉丝。 我喜欢将其与BrowserStack等系统一起使用,以在许多操作系统上的许多不同浏览器之间实现自动化。
"Appium" is a great Selenium-like testing framework that implements the "WebDriver" protocol - formerly JsonWireProtocol.
“ Appium”是一个很棒的类似于Selenium的测试框架,它实现了“ WebDriver ”协议-以前是JsonWireProtocol。
WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.
WebDriver是一个远程控制界面,可以对用户代理进行自省和控制。 它提供了一种与平台和语言无关的有线协议,作为进程外程序远程指示Web浏览器行为的一种方式。
From the Appium website, "Appium is 'cross-platform': it allows you to write tests against multiple platforms (iOS, Android, Windows), using the same API. This enables code reuse between iOS, Android, and Windows testsuites"
在Appium网站上, “ Appium是'跨平台的:它允许您使用相同的API在多个平台(iOS,Android,Windows)上编写测试。这可以在iOS,Android和Windows测试套件之间重用代码”。
Appium is a webserver that exposes a REST API. The WinAppDriver enables Appium by using new APIs that were added in Windows 10 Anniversary Edition that allow you to test any Windows app. That means ANY Windows App. Win32, VB6, WPF, UWP, anything. Not only can you put any app in the Windows Store, you can do full and complete UI testing of those apps with a tool that is already familiar to Web Developers like myself.
Appium是公开REST API的Web服务器。 该WinAppDriver使Appium通过使用Windows 10周年纪念版,让您可以测试任何Windows应用程序中添加的新的API。 这意味着任何Windows应用程序。 Win32,VB6,WPF,UWP等。 您不仅可以在Windows应用商店中放置任何应用程序,还可以使用像我这样的Web开发人员已经熟悉的工具对这些应用程序进行完整和完整的UI测试。
You can write tests in C# and run them from Visual Studio's Test Runner. You can press any button and basically totally control your apps.
您可以使用C#编写测试,并从Visual Studio的“测试运行器”中运行它们。 您可以按任何按钮,基本上完全控制您的应用程序。
// Launch the calculator app
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
CalculatorSession = new RemoteWebDriver(new Uri(WindowsApplicationDriverUrl), appCapabilities);
Assert.IsNotNull(CalculatorSession);
CalculatorSession.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2));
// Make sure we're in standard mode
CalculatorSession.FindElementByXPath("//Button[starts-with(@Name, \"Menu\")]").Click();
OriginalCalculatorMode = CalculatorSession.FindElementByXPath("//List[@AutomationId=\"FlyoutNav\"]//ListItem[@IsSelected=\"True\"]").Text;
CalculatorSession.FindElementByXPath("//ListItem[@Name=\"Standard Calculator\"]").Click();
It's surprisingly easy once you get started.
一旦开始,这非常容易。
public void Addition()
{
CalculatorSession.FindElementByName("One").Click();
CalculatorSession.FindElementByName("Plus").Click();
CalculatorSession.FindElementByName("Seven").Click();
CalculatorSession.FindElementByName("Equals").Click();
Assert.AreEqual("Display is 8 ", CalculatorResult.Text);
}
You can automate any part of Windows, even the Start Menu or Cortana.
您可以自动化Windows的任何部分,甚至“开始”菜单或Cortana。
var searchBox = CortanaSession.FindElementByAccessibilityId("SearchTextBox");
Assert.IsNotNull(searchBox);
searchBox.SendKeys("What is eight times eleven");
var bingPane = CortanaSession.FindElementByName("Bing");
Assert.IsNotNull(bingPane);
var bingResult = bingPane.FindElementByName("88");
Assert.IsNotNull(bingResult);
If you use "AccessibiltyIds" and refer to native controls in a non-locale specific way you can even reuse test code across platforms. For example, you could write sign in code for Windows, iOS, your web app, and even a VB6 Win32 app. ;)
如果您使用“ AccessibiltyIds”并以非语言环境特定的方式引用本机控件,则您甚至可以跨平台重用测试代码。 例如,您可以编写Windows,iOS,Web应用程序甚至VB6 Win32应用程序的登录代码。 ;)
Appium and WebAppDriver a nice alternative to "CodedUI Tests." CodedUI tests are great but just for Windows apps. If you're a web developer or you are writing cross platform or mobile apps you should check it out.
Appium和WebAppDriver是“ CodedUI测试”的不错替代。 CodedUI测试很棒,但仅适用于Windows应用程序。 如果您是Web开发人员,或者正在编写跨平台或移动应用程序,则应进行检查。
Sponsor: Help your team write better, shareable SQL faster! Discover how your whole team can write better, shareable SQL faster with a free trial of SQL Prompt. Write, refactor and share SQL effortlessly, try it now.
赞助者:帮助您的团队更好地编写更好的,可共享SQL ! 通过免费试用SQL Prompt,发现整个团队如何更快地编写更好的,可共享SQL。 轻松编写,重构和共享SQL,请立即尝试。
翻译自: https://www.hanselman.com/blog/winappdriver-test-any-app-with-appiums-seleniumlike-tests-on-windows