April 12, 2017

Test Automation for Windows 10 Surface

Automation

Windows 10 Surface machines are becoming popular laptops. So, many enterprises are developing Windows applications for this platform. Test automation is more important than ever before, including using tools like Appium on Windows. 

Back to top

Can Appium Run on Windows?

You can use Appium on Windows. But you'll need it to use it alongside other tools for full test automation on Windows. 

The best way to use Appium on Windows is alongside WinAppDriver. WinAppDriver drives tests for Appium on Windows. If you're just testing on Windows, you could use WinAppDriver without Appium. But if you're also testing on iOS and Android, it's good to use Appium to manage tests across platforms and devices.

Back to top

Why Windows 10 Surface Needs Test Automation

The default browser on Windows 10 Surface is Microsoft Edge. This has several form factors. It can behave as a laptop or a tablet. So, there’s a lot that’s new and different on these machines — and a lot that can go wrong. Naturally, test automation is the appropriate direction for ensuring high quality of applications and websites on this platform.

Test automation on Windows 10 machines is supported by WinAppDriver. This framework is an area of ongoing investment by Microsoft and the open source community to increase automation capabilities. (By the way, it applies to Mac machines as well.)

However, it’s not as capable as the Appium WebDriver offered on, for example, iOS and Android devices. And even Appium/Selenium do not cover some scenarios, specifically those pertaining to visual screen analysis.

Back to top

How to Use Test Automation on Windows 10 Surface

Here's how to combine native object and visual automation for Surface applications.

1. Create Your Test Cases

Two test cases will be included in the project (see code):

  • Testing the stock Calculator app using native Windows objects (based on this example).
  • Testing a simple web flow in the Edge browser using visual automation.

2. Use a Simple Maven/TestNG Project

Use a simple Maven/TestNG project with the following definitions is the base:

Test NG

Note: I included the WinAppID in the TestNG XML file.

3. Initiate Testing

Utils.java contains the functions to instantiate an Appium or Selenium driver. It’s called from @BeforeTest in testClass.java, which is the body of the test.

In testClass.java, once the driver is initiated in @BeforeTest, we run the testEdge(driver) method to run the Edge test case or testCalculator(driver) for the native test.

testEdge launches the Edge browser, enters a search string into the Bing search box, and validates the results. In this example, I searched “iPad Pro” and waited to see the word “Apple” show up among the results. I also wanted to measure the time it takes to get the results with a UX timer.

Capture

For test stability, close the browser and manage the popup “Close all”.

Capture 2

4. Follow Best Practices

Here are some best practices.

  • All the visual functions are handled in java.
  • I intentionally used all visual functions. This is not a best practice and was done strictly for educational purposes. As a best practice, use native objects where possible to reliably navigate through the app. Visual analysis should be used where you cannot access the objects or for validating accurate rendering or measure responsiveness.
  • It would be easy to change in java to run the testCalculator test:
private static void testCalculator (RemoteWebDriver driver) {
Capture 3

As another best practice, externalize the object names and expected results from the code. And store them in an object repository for easy maintenance and reusability of your scripts.

5. Use Test Frameworks

Test frameworks need to support both native object automation as well as visual automation. Sometimes, to compensate for the Appium driver limitations, one needs to use visual commands.

Here’s a suggested implementation.

The script itself never changes. For example, when using Gherkin for BDD:

Text

Let’s say the search box is not easily accessible as a native object, what I would do is...

Set Separate Object Identifiers

  1. For native objects, using an XPath or object ID
  2. For visual analysis, I would look for the words “web address” on the screen

 

Where to Next

Implement Commands Based on the Driver in Use

At the code layer, I would implement the commands based on the type of driver in use.

For Surface/Windows 10, I would use:

Codee

For iOS/Android, I would enter the text FindElementByID(..).sendKeys()

In other words, the script doesn’t change, only the underlying implementation changes.

Back to top

Get Complete Test Automation With Perfecto

Complete test automation must include both native object automation and visual automation. And when you use Perfecto, you can bring your test automation frameworks and tools together. 

Perfecto integrates with tools like Appium and supports tools like WinAppDriver. Using Perfecto enables you to automate testing across browsers and platforms to make sure your app performs as it should.

See for yourself how Perfecto helps you get complete test automation. You can try it free for 14 days.

Try Perfecto

 

Related Content

Back to top