Appium 测试UWP---sample

上一篇 / 下一篇  2017-04-19 13:39:23 / 个人分类:Appium

 环境准备好后开始练习
 一.新建Junit Test Case
   在Eclipse中Test Project下新建一个Junit Test Case,命名为CalculatorTest

 二.输入测试Calculator的代码:

   
importorg.junit.*;
importorg.openqa.selenium.WebElement;
importorg.openqa.selenium.remote.DesiredCapabilities;
importjava.util.concurrent.TimeUnit;
importjava.net.URL;
importio.appium.java_client.ios.IOSDriver;
publicclassCalculatorTest{
privatestaticIOSDriverCalculatorSession=null;
privatestaticWebElementCalculatorResult=null;
@BeforeClass
publicstaticvoidsetup() {
try{
DesiredCapabilitiescapabilities=newDesiredCapabilities();//运行Windows Calculator,注意app名后的!App是必须保留的,否则你要测的APP运行不起来
capabilities.setCapability("app","Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");//下面是Appium与Eclipse的通信协议.
CalculatorSession=newIOSDriver(newURL("http://127.0.0.1:4723"), capabilities);
CalculatorSession.manage().timeouts().implicitlyWait(2,TimeUnit.SECONDS);
//测试前先清空计算器
CalculatorSession.findElementByName("Clear").click();
CalculatorSession.findElementByName("Seven").click();
CalculatorResult=CalculatorSession.findElementByName("Display is 7");//测试判断是不是按的是数字7
Assert.assertNotNull(CalculatorResult);
}catch(Exceptione){
e.printStackTrace();
}finally{
}
}
@Before
publicvoidClear()
{
CalculatorSession.findElementByName("Clear").click();
Assert.assertEquals("Display is 0",CalculatorResult.getText());
}
@AfterClass
publicstaticvoidTearDown()
{
CalculatorResult=null;
if(CalculatorSession!=null) {//退出计算器
CalculatorSession.quit();
}
CalculatorSession=null;
}
@Test
publicvoidAddition()
{
CalculatorSession.findElementByName("One").click();
CalculatorSession.findElementByName("Plus").click();
CalculatorSession.findElementByName("Seven").click();
CalculatorSession.findElementByName("Equals").click();
Assert.assertEquals("Display is 8",CalculatorResult.getText());
}
@Test
publicvoidCombination()
{
CalculatorSession.findElementByName("Seven").click();

TAG:

fhhh_eyou的个人空间 引用 删除 fhhh_eyou   /   2017-04-19 18:36:41
fhhh_eyou的个人空间 引用 删除 fhhh_eyou   /   2017-04-19 18:35:58
1
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar