乐之网站制作,网络设计工程师是做什么的,怎么样查中企动力做的网站,中国科技成就2019近来通过Appium#xff0c;Robotium等几个框架去了解移动平台自动化测试。Appium官方实例是使用ContactManager.apk#xff0c;而Robotium使用的是SDK自带的Notepad.apk#xff0c;为了方便比较#xff0c;在了解Appium的同时把实例修改成跟Robotium一致的Notepad.apk并记录…近来通过AppiumRobotium等几个框架去了解移动平台自动化测试。Appium官方实例是使用ContactManager.apk而Robotium使用的是SDK自带的Notepad.apk为了方便比较在了解Appium的同时把实例修改成跟Robotium一致的Notepad.apk并记录下其中一个Case如下1.package majcit.com.AppiumDemo;2.3.import io.appium.java_client.AppiumDriver;4.import io.appium.java_client.TouchAction;5.6.import java.io.File;7.import java.net.URL;8.import java.util.List;9.10.import org.junit.Test;11.import org.junit.After;12.import org.junit.Before;13.import org.openqa.selenium.By;14.import org.openqa.selenium.WebElement;15.import org.openqa.selenium.remote.DesiredCapabilities;16.import static org.hamcrest.Matchers.*;17.import static org.hamcrest.MatcherAssert.assertThat;18.19./**20. * Unit test for simple App.21. */22.public class NoetPadTest {23. /**24. * Create the test case25. *26. * param testName name of the test case27. */28. private AppiumDriver driver;29.30. Before31. public void setUp() throws Exception {32. // set up appium33. File classpathRoot new File(System.getProperty(user.dir));34. File appDir new File(classpathRoot, apps);35. File app new File(appDir, NotePad.apk);36. DesiredCapabilities capabilities new DesiredCapabilities();37. capabilities.setCapability(deviceName,Android);38. //capabilities.setCapability(platformVersion, 4.2);39. capabilities.setCapability(platformName, Android);40. //capabilities.setCapability(app, app.getAbsolutePath());41. capabilities.setCapability(appPackage, com.example.android.notepad);42. capabilities.setCapability(appActivity, com.example.android.notepad.NotesList);43. //capabilities.setCapability(appActivity, .NotesList);44. driver new AppiumDriver(new URL(http://127.0.0.1:4723/wd/hub), capabilities);45. }46.47. After48. public void tearDown() throws Exception {49. driver.quit();50. }51.52. Test53. public void addNoteCNTitle() throws InterruptedException{54. //Evoke the system menu option55. driver.sendKeyEvent(82);56.57.58. try {59. Thread.sleep(1000);60. }catch(Exception e) {61. System.out.println(e.getMessage());62. }63.64. //Click on the Add Note menu entry65. WebElement el driver.findElement(By.name(Add note));66. el.click();67.68. //Enter the note info and save it69. WebElement text driver.findElementByClassName(android.widget.EditText);70. text.sendKeys(Note 1);71.72. driver.sendKeyEvent(82);73. el driver.findElement(By.name(Save));74. el.click();75.76. //Find out the new added note entry77. List entries driver.findElements(By.className(android.widget.TextView));78.79. WebElement targetEntry null;80. for(WebElement entry : entries) {81. if(entry.getText().equals(Note1)) {82. targetEntry entry;83. break;84. }85. }86.87. //Long press on the men entry to call out the context menu options88. TouchAction action new TouchAction(driver);89. action.longPress(targetEntry);90. //action.moveTo(we,240,10);91. action.perform();92.93. //Find out the menu entry of Delete94. WebElement optionListView driver.findElement(By.className(android.widget.ListView));95. List options optionListView.findElements(By.className(android.widget.TextView));96. WebElement delete null;97. for (WebElement option:options) {98. if (option.getText().equals(Delete)) {99. delete option;100. break;101.102. }103. }104.105. assertThat(delete,notNullValue());106.107. //Delete the menu entry108. delete.click();109.110. try {111. Thread.sleep(1000);112. }catch(Exception e) {113. System.out.println(e.getMessage());114. }115.116.117.118. }119.120.}本文地址https://blog.csdn.net/qq_31344287/article/details/108732301如您对本文有疑问或者有任何想说的请点击进行留言回复万千网友为您解惑