我搜索了自动化Windows Phone 8应用程序的UI,但没有找到任何有用的工具或框架,那么有没有任何框架可以自动化Windows Phone 8应用程序的UI?
我搜索了自动化Windows Phone 8应用程序的UI,但没有找到任何有用的工具或框架,那么有没有任何框架可以自动化Windows Phone 8应用程序的UI?
您可以使用Winium。
为什么选择Winium?
您可以使用Selenium WebDriver测试Web应用程序,使用Appium测试iOS和Android应用程序。现在,您还可以使用基于Selenium的工具来测试Windows应用程序。一些好处是什么?就像Appium所说:
您可以使用任何喜欢的开发工具编写测试,使用任何WebDriver兼容语言,如Java、Objective-C、JavaScript(以Promise、Callback或Generator方式)、PHP、Python、Ruby、C#、Clojure或Perl,使用Selenium WebDriver API和特定于语言的客户端库。
您可以使用任何测试框架。
它是如何工作的?
Winium.StoreApps由两个基本部分组成:
Winium.StoreApps.Driver实现了Selenium远程WebDriver,并侦听JsonWireProtocol命令。它负责启动模拟器、部署AUT、模拟输入、将命令转发到Winium.StoreApps.InnerServer等。
Winium.StoreApps.InnerServer(应嵌入到AUT中)与Winium.StoreApps.Driver.exe通信并执行不同的命令,如查找元素、获取或设置文本值、属性等。
测试样例:
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();
}
}
我正在使用这个开源项目来进行Windows Phone自动化测试,它对我来说工作得相当不错。
请查看这个项目:http://code.msdn.microsoft.com/wpapps/Simple-UI-Test-for-Windows-dc0573a9
它展示了如何模拟点击按钮和检索另一个元素的值。
我自己还没有尝试过,但原理似乎是:
创建一个单独的测试项目
在测试初始化代码中,实例化您应用程序项目中的页面:
public void Init()
{
mp1 = new PhoneApp1.MainPage();
}
你的测试通过引用已实例化的页面来查找元素:
[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");
}
我目前正在研究CodedUI测试,因为它们可能是解决方案。 以下是来自Microsoft应用生命周期管理博客的官方声明:http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/05/using-coded-ui-to-test-xaml-based-windows-phone-apps.aspx
文章中有一些非常具体的细节,我想强调一下:
用于在XAML应用程序中托管HTML内容的WebView控件目前不受支持。
此外,
您还可以与Shell控件交互-这些控件不是XAML,但对于测试您的应用程序E2E至关重要-例如磁贴、确认对话框等。这些控件由操作系统提供,而不是XAML。
最后提到的限制: