Appium中怎么創(chuàng)建一個Note

這篇文章給大家介紹Appium中怎么創(chuàng)建一個Note,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。

公司主營業(yè)務(wù):成都網(wǎng)站設(shè)計、成都做網(wǎng)站、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出碭山免費(fèi)做網(wǎng)站回饋大家。

近來通過Appium,Robotium等幾個框架去了解移動平臺自動化測試。Appium官方實例是使用ContactManager.apk,而Robotium使用的是SDK自帶的Notepad.apk,為了方便比較,在了解Appium的同時把實例修改成跟Robotium一致的Notepad.apk并記錄下其中一個Case如下:

package majcit.com.AppiumDemo;  import io.appium.java_client.AppiumDriver; import io.appium.java_client.TouchAction;  import java.io.File; import java.net.URL; import java.util.List;  import org.junit.Test; import org.junit.After; import org.junit.Before; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat;  /**  * Unit test for simple App.  */ public class NoetPadTest {     /**      * Create the test case      *      * @param testName name of the test case      */ 	private AppiumDriver driver;      @Before     public void setUp() throws Exception {         // set up appium         File classpathRoot = new File(System.getProperty("user.dir"));         File appDir = new File(classpathRoot, "apps");         File app = new File(appDir, "NotePad.apk");         DesiredCapabilities capabilities = new DesiredCapabilities();         capabilities.setCapability("deviceName","Android");         //capabilities.setCapability("platformVersion", "4.2");         capabilities.setCapability("platformName", "Android");         //capabilities.setCapability("app", app.getAbsolutePath());         capabilities.setCapability("appPackage", "com.example.android.notepad");         capabilities.setCapability("appActivity", "com.example.android.notepad.NotesList");         //capabilities.setCapability("appActivity", ".NotesList");         driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);     }      @After     public void tearDown() throws Exception {         driver.quit();     }      @Test     public void addNoteCNTitle() throws InterruptedException{         //Evoke the system menu option     	driver.sendKeyEvent(82);                   try {         	Thread.sleep(1000);         }catch(Exception e) {         	System.out.println(e.getMessage());         }                  //Click on the "Add Note" menu entry         WebElement el = driver.findElement(By.name("Add note"));         el.click();                  //Enter the note info and save it         WebElement text = driver.findElementByClassName("android.widget.EditText");         text.sendKeys("Note 1");                  driver.sendKeyEvent(82);         el = driver.findElement(By.name("Save"));         el.click();                  //Find out the new added note entry         List <WebElement> entries = driver.findElements(By.className("android.widget.TextView"));                  WebElement targetEntry = null;         for(WebElement entry : entries) {         	if(entry.getText().equals("Note1")) {         		targetEntry = entry;         		break;         	}         }                  //Long press on the men entry to call out the context menu options         TouchAction action = new TouchAction(driver);         action.longPress(targetEntry);         //action.moveTo(we,240,10);         action.perform();     	         //Find out the menu entry of "Delete"         WebElement optionListView = driver.findElement(By.className("android.widget.ListView"));         List <WebElement> options = optionListView.findElements(By.className("android.widget.TextView"));         WebElement delete = null;         for (WebElement option:options) {         	if (option.getText().equals("Delete")) {         		delete = option;         		break;         		         	}         }                  assertThat(delete,notNullValue());                  //Delete the menu entry         delete.click();                  try {         	Thread.sleep(1000);         }catch(Exception e) {         	System.out.println(e.getMessage());         }                                }      }

關(guān)于Appium中怎么創(chuàng)建一個Note就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

文章標(biāo)題:Appium中怎么創(chuàng)建一個Note
轉(zhuǎn)載源于:http://muchs.cn/article24/isjeje.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、軟件開發(fā)、移動網(wǎng)站建設(shè)網(wǎng)站制作、定制開發(fā)Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營