UI Automation in Windows Phone 8

I was looking for user interface automation in Windows Phone 8 applications, and I did not have any useful tool or framework for this, is there any infrastructure for automating the UI application in Windows Phone 8?

+3
source share
3 answers

You can use Winium.

Why winium?

  • You have Selenium WebDriver for testing web applications, Appium for
    testing iOS and Android applications. And now you have Selenium-based
    Tools for testing Windows applications. What are some of the benefits? As Appium said:

  • You can write tests using your favorite dev tools, using any WebDriver-compatible language such as Java, Objective-C, JavaScript with Node.js (in promises, callbacks or generators), PHP, Python, Ruby, C #, Clojure or Perl with the Selenium WebDriver API and language client libraries.

  • You can use any testing environment.

How it works?

Winium.StoreApps consists of two main parts:

  • Winium.StoreApps.Driver implements Selenium Remote WebDriver and listens for JsonWireProtocol commands. He is responsible for running the emulator, deploying AUT, simulating input, forwarding commands to Winium.StoreApps.InnerServer, etc.

  • Winium.StoreApps.InnerServer (the one that should be built into AUT) interacts with Winium.StoreApps.Driver.exe and executes various commands, such as finding elements, getting or setting text values, properties, etc. inside your application.

enter image description here

Test Samples:

Python

 # coding: utf-8 import unittest from selenium.webdriver import Remote class TestMainPage(unittest.TestCase): desired_capabilities = { "app": "C:\\YorAppUnderTest.appx" } def setUp(self): self.driver = Remote(command_executor="http://localhost:9999", desired_capabilities=self.desired_capabilities) def test_button_tap_should_set_textbox_content(self): self.driver.find_element_by_id('SetButton').click() assert 'CARAMBA' == self.driver.find_element_by_id('MyTextBox').text def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main() Please check the link below. It can help you a lot. You just have to follow guidance in this project. 

C#

 using System; using NUnit.Framework; using OpenQA.Selenium.Remote; [TestFixture] public class TestMainPage { public RemoteWebDriver Driver { get; set; } [SetUp] public void SetUp() { var dc = new DesiredCapabilities(); dc.SetCapability("app", "C:\\YorAppUnderTest.appx"); this.Driver = new RemoteWebDriver(new Uri("http://localhost:9999"), dc); } [Test] public void TestButtonTapShouldSetTextboxContent() { this.Driver.FindElementById("SetButton").Click(); Assert.IsTrue("CARAMBA" == this.Driver.FindElementById("MyTextBox").Text); } [TearDown] public void TearDown() { this.Driver.Quit(); } } 

Winium.StoreApps

I am currently working on Windows Phone Automation using this openource

project, it works very well for me.

+2
source

Take a look at this project: http://code.msdn.microsoft.com/wpapps/Simple-UI-Test-for-Windows-dc0573a9

Shows how to simulate a button click and retrieve the value of another item.

I have not tried this myself, but the principle is as follows:

Create a separate test project

In your test init code, create an instance of the page from your application project:

 public void Init() { mp1 = new PhoneApp1.MainPage(); } 

Your tests find elements by linking to this instance page:

 [TestMethod] [Description("Test1: Clicking button passes")] public void PassedTest() { var b = mp1.FindName("button1") as Button; ButtonAutomationPeer peer = new ButtonAutomationPeer(b); IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; invokeProv.Invoke(); Assert.AreEqual((mp1.FindName("AppTitle") as TextBlock).Text.ToString(), "Results"); } 
0
source

I am currently studying CodedUI tests because they can be a solution. Here is the official expression from the Microsoft Application Lifecycle application management blog: http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/05/using-coded-ui-to-test-xaml-based-windows-phone -apps.aspx

The article has some very specific details that I would like to highlight:

  • You need to have at least update Visual Studio 2013 Update 2
  • Article citation:

The WebView control used to host HTML content in a XAML application is not currently supported.

  • Also

    You can also interact with Shell controls - controls that are not XAML, but necessary for testing your E2E application - for example, tiles, confirmation dialogs, etc. These controls are provided by the OS and are not XAML.

  • Last limitation:

Only XAML-based applications are supported. Silverlight and HTML 5 based applications cannot be tested using an encoded interface.

I will update my answer whenever I get practice with CodedUI for Windows Phone 8 applications - I need to write tests myself and run them on a real device.

0
source

All Articles