首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >windows phone 8应用程序中的UI自动化

windows phone 8应用程序中的UI自动化
EN

Stack Overflow用户
提问于 2013-05-14 21:36:47
回答 3查看 4.4K关注 0票数 3

我在windows phone 8应用程序中搜索了自动化UI,但我没有得到任何有用的工具或框架,那么在windows phone 8中有没有框架可以自动化UI应用程序?

EN

回答 3

Stack Overflow用户

发布于 2016-03-15 15:21:40

您可以使用Winium。

为什么选择Winium?

  • 您有Selenium WebDriver用于测试web应用程序,Appium用于

测试iOS和安卓应用程序。现在你有了基于硒的

测试Windows应用程序的工具。有哪些好处?正如Appium所说:

  • 您可以使用任何与WebDriver兼容的语言来使用您喜欢的开发工具编写测试,这些语言包括Java、Objective-C、JavaScript with Node.js ( promise、回调或生成器风格)、PHP、Python、Ruby、C#、Clojure或具有Selenium WebDriver API和特定于语言的客户端库的Node.js。

  • 您可以使用任何测试框架。

它是如何工作的?

Winium.StoreApps由两个基本部分组成:

  1. Winium.StoreApps.Driver实现Selenium远程WebDriver并侦听JsonWireProtocol命令。它负责启动仿真器、部署自动测试、模拟输入、将命令转发到Winium.StoreApps.InnerServer等。

在application.中,

  1. Winium.StoreApps.InnerServer (应该嵌入到AUT中)与Winium.StoreApps.Driver.exe通信并执行不同的命令,比如查找元素、获取或设置文本值、属性等

测试示例:

Python

代码语言:javascript
复制
# 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#

代码语言:javascript
复制
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

我目前正在使用这个开源软件开发Windows Phone自动化

项目,它对我来说工作得很好。

票数 2
EN

Stack Overflow用户

发布于 2013-05-15 08:53:05

看看这个项目:http://code.msdn.microsoft.com/wpapps/Simple-UI-Test-for-Windows-dc0573a9

它展示了如何模拟单击一个按钮并检索另一个元素的值。

我自己还没有尝试过,但原理似乎是:

创建单独的测试项目

在测试初始化代码中,实例化应用程序项目中的页面:

代码语言:javascript
复制
public void Init() 
{                
    mp1 = new PhoneApp1.MainPage(); 
} 

您的测试通过引用该实例化的页面来查找元素:

代码语言:javascript
复制
[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
EN

Stack Overflow用户

发布于 2015-01-21 21:01:42

我目前正在研究CodedUI测试,因为它们可能是解决方案。以下是微软应用程序生命周期管理博客的官方声明:http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/05/using-coded-ui-to-test-xaml-based-windows-phone-apps.aspx

文章中有一些非常具体的细节,我想强调一下:

  • 您需要至少拥有Visual Studio 2013更新2
  • 引用文章:

当前不支持用于在XAML应用程序中承载

内容的WebView控件。

您还可以与外壳控件进行交互-这些控件不是XAML,但对于测试应用程序E2E是必不可少的-例如磁贴、确认对话框等。这些控件由操作系统提供,不是XAML。

  • 提到的最后一个限制:

仅支持基于XAML的商店应用程序。基于Silverlight和HTML5的应用程序无法使用编码的UI进行测试。

每当我在Windows phone8应用程序上使用CodedUI时,我都会更新我的回复-我需要自己编写测试并在实际的设备上运行它们。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16544730

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档