2013-05-14 108 views
3

...我已經尋找在Windows Phone的UI自動化8個應用程序,我沒有得到任何有用的工具或框架,以便有任何框架來自動的Windows Phone 8用戶界面應用程序?UI自動化

+1

你是什麼意思的自動化?你的意思是編寫自己運行的代碼嗎?你的意思是動畫嗎?你能提供更多的信息嗎? – 2013-05-14 13:39:49

回答

0

看一看這個項目: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"); 
} 
0

我目前正在調查CodedUI測試,因爲他們可能是解決方案。 這裏是從Microsoft應用程序生命週期管理博客的官方聲明: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應用程序的HTML內容

WebView控件是真正水流目前不支持 。

  • 而且

    您也可以與殼牌交互控制 - 這不 XAML控制,但必不可少的應用測試E2E - 如瓷磚, 確認對話框,等等。這些控件是由操作系統提供, 不是XAML。

  • 提到的最終限制:

只有基於XAML應用程序商店支持。 Silverlight和HTML 5個基於 應用程序可以不使用編碼的UI進行測試。

每當我在CodedUI for Windows Phone 8應用程序中獲得一些練習時,我都會更新我的回覆 - 我需要自己編寫測試並在實際設備上運行測試。

2

您可以使用Winium。

爲什麼Winium?

  • 你有硒webdriver的網絡應用程序的測試,Appium爲iOS和Android應用的
    測試。現在,您也有基於Selenium的
    測試Windows應用程序的工具。什麼是一些好處? 正如Appium說:

  • 您可以編寫使用任何 的webdriver兼容的語言你最喜歡的開發工具的測試,如的Java,Objective-C中的JavaScript 用Node.js的(以諾,回調或生成器風格),PHP,Python, Ruby,C#,Clojure或Perl與Selenium WebDriver API和 語言特定的客戶端庫。

  • 您可以使用任何測試框架。

它是如何工作的?

Winium.StoreApps包括兩個主要部分:

  1. Winium.StoreApps.Driver實現硒的遠程的webdriver和 監聽JsonWireProtocol命令。它是負責啓動 模擬器,部署AUT,模擬輸入,轉發命令 Winium.StoreApps.InnerServer等

  2. Winium.StoreApps.InnerServer(在應該被嵌入到一個 AUT)與Winium.StoreApps.Driver.exe進行通信並執行 不同的命令,例如查找元素,在應用程序內部獲取或設置文本 值,屬性等。

enter image description here

測試樣品:

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

我目前在Windows Phone的自動化工作使用這個開源

項目,它非常適合我。