Reputation: 41
i have searched for automating UI in windows phone 8 applications and i did not get any useful tool or framework for that so is there any framework to automate UI application in windows phone 8?
Upvotes: 3
Views: 4460
Reputation: 906
You can use Winium.
Why Winium?
You have Selenium WebDriver for testing of web apps, Appium for
testing of iOS and Android apps. And now you have Selenium-based
tools for testing of Windows apps too. What are some of the benefits? As said by Appium:
You can write tests with your favorite dev tools using any WebDriver-compatible language such as Java, Objective-C, JavaScript with Node.js (in promise, callback or generator flavors), PHP, Python, Ruby, C#, Clojure, or Perl with the Selenium WebDriver API and language-specific client libraries.
You can use any testing framework.
How it works?
Winium.StoreApps consists of two essential parts:
Winium.StoreApps.Driver implements Selenium Remote WebDriver and listens for JsonWireProtocol commands. It is responsible for launching emulator, deploying AUT, simulating input, forwarding commands to Winium.StoreApps.InnerServer, etc.
Winium.StoreApps.InnerServer (the one that should be embedded into AUT) communicates with Winium.StoreApps.Driver.exe and executes different commands, like finding elements, getting or setting text values, properties, etc., inside your application.
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();
}
}
I am currently working on a Windows Phone Automation using this opensource
project, it works pretty well for me.
Upvotes: 2
Reputation: 618
I am currently investigating CodedUI tests because they may be the solution. Here is the official statement from the Microsoft Application Lifecycle Management blog: http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/05/using-coded-ui-to-test-xaml-based-windows-phone-apps.aspx
There are some very specific details in the article that I would like to highlight:
WebView control used to host HTML content in a XAML app is currently not supported.
Also
You can also interact with Shell controls – controls that are not XAML, but essential for testing your app E2E – such as the tiles, confirmation dialogs, etc. These controls are provided by the OS and are not XAML.
The final limitation mentioned:
Only XAML based store apps are supported. Silverlight and HTML 5 based apps cannot be tested using Coded UI.
I will update my reply whenever I have gained some practice with CodedUI for Windows Phone 8 apps - I need to write the tests myself and run them on an actual device.
Upvotes: 0
Reputation: 3162
Take a look at this project: http://code.msdn.microsoft.com/wpapps/Simple-UI-Test-for-Windows-dc0573a9
It shows how to simulate clicking on a button and retrieving the value of another element.
I haven't tried this myself, but the principle seems to be:
Create a separate test project
In your test initialization code, instantiate a page from your app project:
public void Init()
{
mp1 = new PhoneApp1.MainPage();
}
Your tests find elements by referring to that instantiated 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");
}
Upvotes: 0