<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    qileilove

    blog已經轉移至github,大家請訪問 http://qaseven.github.io/

    安裝運行Appium初體驗

     最近有空玩了一下Appium,記錄一下
      1.下載Appium for windows,現在是0.12.3版本
      解壓后如下圖
      雙擊Appium.exe就能啟動Appium界面
      點擊Launch開啟服務
      2. 下載Android SDK
      解壓后
      3. 配置系統環境變量
      ANDROID_HOME: C:\adt-bundle-windows-x86_64-20131030\sdk
      Path添加: %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools
     4. 啟動AVD,耗資源啊,這時候我T400的CPU已經100%了
      5. 編寫Test,使用ADT安裝好Maven插件,創建一個Maven項目,添加一個文件夾apps用來存放被測的app,這里測試的是ContactManager.apk
      pom.xml添加如下依賴
    1   <dependencies>
    2     <dependency>
    3             <groupId>junit</groupId>
    4             <artifactId>junit</artifactId>
    5             <version>4.11</version>
    6             <scope>test</scope>
    7         </dependency>
    8         <dependency>
    9             <groupId>org.seleniumhq.selenium</groupId>
    10             <artifactId>selenium-java</artifactId>
    11             <version>LATEST</version>
    12             <scope>test</scope>
    13         </dependency>
    14   </dependencies>
     編寫AndroidContactsTest
    1 package com.guowen.appiumdemo;
    2
    3 import org.junit.After;
    4 import org.junit.Before;
    5 import org.junit.Test;
    6 import org.openqa.selenium.*;
    7 import org.openqa.selenium.interactions.HasTouchScreen;
    8 import org.openqa.selenium.interactions.TouchScreen;
    9 import org.openqa.selenium.remote.CapabilityType;
    10 import org.openqa.selenium.remote.DesiredCapabilities;
    11 import org.openqa.selenium.remote.RemoteTouchScreen;
    12 import org.openqa.selenium.remote.RemoteWebDriver;
    13 import java.io.File;
    14 import java.net.URL;
    15 import java.util.List;
    16
    17 public class AndroidContactsTest {
    18     private WebDriver driver;
    19
    20     @Before
    21     public void setUp() throws Exception {
    22         // set up appium
    23         File classpathRoot = new File(System.getProperty("user.dir"));
    24         File appDir = new File(classpathRoot, "apps/ContactManager");
    25         File app = new File(appDir, "ContactManager.apk");
    26         DesiredCapabilities capabilities = new DesiredCapabilities();
    27         capabilities.setCapability("device","Android");
    28         capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
    29         capabilities.setCapability(CapabilityType.VERSION, "4.4");
    30         capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
    31         capabilities.setCapability("app", app.getAbsolutePath());
    32         capabilities.setCapability("app-package", "com.example.android.contactmanager");
    33         capabilities.setCapability("app-activity", ".ContactManager");
    34         driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    35     }
    36
    37     @After
    38     public void tearDown() throws Exception {
    39         driver.quit();
    40     }
    41
    42     @Test
    43     public void addContact(){
    44         WebElement el = driver.findElement(By.name("Add Contact"));
    45         el.click();
    46         List<WebElement> textFieldsList = driver.findElements(By.tagName("textfield"));
    47         textFieldsList.get(0).sendKeys("Some Name");
    48         textFieldsList.get(2).sendKeys("Some@example.com");
    49         driver.findElement(By.name("Save")).click();
    50     }
    51
    52     public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
    53         private RemoteTouchScreen touch;
    54
    55         public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {
    56             super(remoteAddress, desiredCapabilities);
    57             touch = new RemoteTouchScreen(getExecuteMethod());
    58         }
    59
    60         public TouchScreen getTouch() {
    61             return touch;
    62         }
    63     }
    64 }
      6. 運行Test,注意AVD里的Android如果沒有解鎖需要先解鎖
      這時候我們可以看到AVD在運行了,
      同時Appium的命令行有對應的輸出
      7. 更多信息請參考Appium的Github

    posted on 2014-11-27 11:57 順其自然EVO 閱讀(1370) 評論(0)  編輯  收藏 所屬分類: android

    <2014年11月>
    2627282930311
    2345678
    9101112131415
    16171819202122
    23242526272829
    30123456

    導航

    統計

    常用鏈接

    留言簿(55)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲AV无码不卡在线播放| 免费人成网站在线观看10分钟| 国产精品无码一区二区三区免费| 日韩精品一区二区亚洲AV观看| 国产无遮挡无码视频免费软件| 国产成人亚洲精品影院| 国产免费久久精品丫丫| 中文字幕亚洲激情| 久久国产乱子伦精品免费午夜 | 亚洲AV日韩AV鸥美在线观看| jizz免费观看| 亚洲色大成网站WWW久久九九| 三根一起会坏掉的好痛免费三级全黄的视频在线观看 | 免费无码又黄又爽又刺激| 亚洲欧洲日产国产最新| 1024免费福利永久观看网站| 亚洲人成7777| 国产一级一片免费播放i| 一区二区在线免费视频| 亚洲精品无码乱码成人| 四虎影视在线影院在线观看免费视频| 亚洲人成网站在线播放影院在线| 免费v片在线观看视频网站| 日韩亚洲产在线观看| 免费在线观看a级毛片| 中文字幕av无码不卡免费| 久久亚洲sm情趣捆绑调教| 99精品国产免费久久久久久下载| 亚洲色大成WWW亚洲女子| 亚洲人成无码网WWW| 久久久久久AV无码免费网站下载| 亚洲人色大成年网站在线观看| 免费看的成人yellow视频| 人与动性xxxxx免费| 久久亚洲AV成人无码电影| 免费激情视频网站| 中文字幕免费观看视频| 亚洲中字慕日产2021| 亚洲精品尤物yw在线影院| 84pao强力永久免费高清 | 全黄A免费一级毛片|