qileilove

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

          基于APPIUM的移動自動化測試

           Appium一款開源自動化測試工具,可以非常快捷的為iOS和Android移動平臺創建功能自動化測試用例。相比其他的移動自動化測試工具,Appium測試由于調用了Selenium的client庫使其可以使用任意的語言,包括PythonRuby、Node.js,Objective,java等。

            本文我們主要討論如何通過junit java example tests測試完成iOS sample apps的測試(此處我們還會創建TestNG example Tests)

            當然在開始之前,我們首先需要下載Appium,下載地址為https://github.com/appium/appium,根據安裝說明我們可以完成Appium的安裝。

            運行以下命令行構建sample projects:

          grunt buildApp:TestApp
          grunt buildApp:UICatalog

            一旦sample projects完成構建,即可通過以下命令啟動Appium:

          grunt appium

            變更工作目錄到sample-code/examples/java/junit,運行測試

          mvn test

            或運行單個測試:

          mvn -Dtest=com.saucelabs.appium.SimpleTest test

            Java Appium測試與Selenium Test非常的相似,你可以創建一個RemoteWebDriver實例并指定DesiredCapabilities,腳本如下:

          @Before
          public void setUp() throws Exception {
              // set up appium against a local application
              File appDir = new File(System.getProperty("user.dir"), "../../../apps/TestApp/build/Release-iphonesimulator");
           
              File app = new File(appDir, "TestApp.app");
              DesiredCapabilities capabilities = new DesiredCapabilities();
              capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
              capabilities.setCapability(CapabilityType.VERSION, "6.0");
              capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
           
              //tell Appium where the location of the app is
              capabilities.setCapability("app", app.getAbsolutePath());
           
              //create a RemoteWebDriver, the default port for Appium is 4723
              driver = new RemoteWebDriver(new URL(http://127.0.0.1:4723/wd/hub), capabilities);
          }

            完成以上腳本后即可直接通過類似selenium測試的方式完成測試腳本:

          @Test
          public void example() throws Exception {
           
              // find an element by tag name
              WebElement button = driver.findElement(By.tagName("button"));
              button.click();
           
              // get the value of the element
              WebElement texts = driver.findElement(By.tagName("staticText"));
              assertEquals(texts.getText(), "some expected value");
          }

          posted on 2013-04-18 10:07 順其自然EVO 閱讀(540) 評論(0)  編輯  收藏 所屬分類: selenium and watir webdrivers 自動化測試學習

          <2013年4月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          導航

          統計

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 布尔津县| 衡南县| 开鲁县| 汝州市| 永兴县| 土默特左旗| 特克斯县| 平舆县| 泰顺县| 宜宾市| 鹿泉市| 霍州市| 桐乡市| 平舆县| 郑州市| 惠州市| 平顶山市| 怀化市| 池州市| 涿州市| 翼城县| 陇西县| 佛山市| 桦甸市| 特克斯县| 年辖:市辖区| 天祝| 措勤县| 桂阳县| 宽甸| 仁寿县| 沧州市| 武宣县| 彩票| 黎川县| 洪江市| 马尔康县| 宕昌县| 社会| 汽车| 井陉县|