<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Selendroid 入門實例教程 > 原文: [https://www.guru99.com/introduction-to-selendroid.html](https://www.guru99.com/introduction-to-selendroid.html) 您是否曾經開發過 Android 應用程序并將其發布到 Google Play? 如果收到類似以下內容的用戶評論,該怎么辦? ![Introduction to Selendroid](https://img.kancloud.cn/68/33/68335ff8bea4cb8cd3cc29b1a051cc4f_339x265.png "Introduction to Selendroid") 當您將應用發布到 Google Play 時,必須對其進行良好的測試,以避免潛在的錯誤。 發布應用之前,應執行大量測試方案。 要節省[測試](/software-testing.html)的工作量,您需要一個測試工具。 **Selendroid 是適用于 Android 應用的最佳測試工具之一。** * [什么是 Selendroid?](#1) * [為什么我們需要 Selendroid?](#2) * [Selendroid 體系結構](#3) * [Selendroid](#4) 入門 * [設置一個 Selendroid 環境](#5) * [如何啟動 Selendroid](#6) * [Selendroid 基本命令](#7) * [使用 Selendroid](#8) 開始您的首次測試 ## 什么是 Selendroid? Selendroid 是用于多種類型的移動應用程序的測試自動化框架:**本機**和**混合** Android 應用程序和**移動**網絡。 ![Introduction to Selendroid](https://img.kancloud.cn/27/0f/270f25d97b9738efbb8b60a9f445288a_822x266.png "Introduction to Selendroid") 您可以使用 [Selenium](/selenium-tutorial.html) 2 客戶端 API 編寫測試。 因為 Selendroid 仍將現有的 Selenium 基礎結構重用于 Web Selendroid 是功能強大的測試工具。 它可以在**仿真器**和實際的**設備**上使用 ![Introduction to Selendroid](https://img.kancloud.cn/49/9f/499f5d0f95d182d7d20b1d929c5521ba_451x432.png "Introduction to Selendroid") ## 為什么我們需要 Selendroid? Selendroid 是一個很棒的測試工具。 但是您可能仍然懷疑它的用處。 ![Introduction to Selendroid](https://img.kancloud.cn/a3/c7/a3c766c98197d4ccb9ddecb45fa86287_229x257.png "Introduction to Selendroid") 本節將介紹 Selendroid 的重要功能,以回答為什么需要 Selendroid 的問題。 ![Introduction to Selendroid](https://img.kancloud.cn/17/33/173341af17ad9face7d3257d80636d87_575x385.png "Introduction to Selendroid") * 您可以使用 Selendroid 測試被測試的應用程序,而無需對該應用程序進行任何修改。 您只需要在計算機上安裝二進制文件( [APK](http://www.androidpit.com/android-for-beginners-what-is-an-apk-file) )。 為了在設備上安裝二進制文件,測試應用程序和移動應用程序必須使用相同的簽名密鑰進行簽名 * Selendroid 測試應用程序可以同時與多個設備或模擬器進行交互。 這是 Selendroid 的一大優勢。 因此,您可以使用各種 Android 設備測試您的應用,以檢查兼容性。 * Selendroid 可以模擬用戶在應用程序上的操作,例如在設備上進行觸摸,滑動,拖放等操作 * 您可以在測試過程中更改硬件設備(即插拔),而無需重新啟動或停止測試。 Selendroid 自動識別新設備 * 與 Android API 版本相對應,Selendroid 還支持新的 Android API(從 API 10 到 API 19)。 * Selendroid 還具有一些內置的檢查器工具,可幫助您識別被測應用程序的 UI 元素。 例如 ID 按鈕,文本字段,文本視圖… ## Selendroid 體系結構 Selendroid 基于 [Android 工具框架](http://developer.android.com/tools/testing/testing_android.html)。 Selendroid 測試是基于 Selenium Web 驅動程序客戶端 API 編寫的,因此它支持與當前 Selenium 框架的完全集成。 下圖描述了 Selendroid 的體系結構 ![Introduction to Selendroid](https://img.kancloud.cn/26/a0/26a0a06de79c4973bbacacd1de595aa6_1032x546.png "Introduction to Selendroid") Selendroid 包含 4 個主要成分: ![Introduction to Selendroid](https://img.kancloud.cn/3a/11/3a111e674b6f6ff32bd07f178e5f30b6_456x385.png "Introduction to Selendroid") * *Web 驅動程序客戶端* –基于 Selenium 的 [Java](/java-tutorial.html) 客戶端庫。 該庫應該安裝在計算機上(用于開發測試用例) * *Selendroid-Server* –運行在受測應用中的 Android 設備或模擬器上的服務器。 這是 Selendroid 體系結構的主要組件 * *Android Driver-App* -內置的 Android 驅動程序 Web View 應用程序,用于測試移動網絡。 * *Selendroid-Standalone* –此組件用于安裝 Selendroid 服務器和被測應用程序(AUT) ## Selendroid 入門 您已經知道 Selendroid 的重要性。 現在,讓我們與 Selendroid 擦干雙手。 在使用 Selendroid 進行第一次測試之前,需要完成 3 個步驟 ![Introduction to Selendroid](https://img.kancloud.cn/ed/c6/edc63ce6f201eb11e51c9924cabbaaf2_715x273.png "Introduction to Selendroid") ## 設置一個 Selendroid 環境 Selendroid 可以在 Window, [Linux](/unix-linux-tutorial.html) 和 Mac OS 上運行。 在本教程中,我們將在 Window OS 中設置 Selendroid。 在使用 Selendroid 之前,您需要先安裝以下軟件包 * [Java SDK](/install-java.html) (minimum 1.6) 您必須接受許可協議并下載 Java 安裝程序(在您的操作系統上選擇 x64 或 x86) ![Introduction to Selendroid](https://img.kancloud.cn/ae/6d/ae6ddbe3161f721733ff5bc77b32d9e0_536x37.png "Introduction to Selendroid") 下載并安裝 Java SDK 作為常規軟件 * 最新版本的 [Android SDK](https://developer.android.com/studio?pkg=tools) * 您的計算機必須至少有一個 Android 虛擬設備(AVD),或一臺真正的 Android 設備已插入 PC。 * [具有依賴項的 Selendroid 獨立](https://github.com/selendroid/selendroid/releases/download/0.11.0/selendroid-standalone-0.11.0-with-dependencies.jar), [Selendroid 客戶端](https://repo1.maven.org/maven2/io/selendroid/selendroid-client/0.10.0/selendroid-client-0.10.0.jar)和 [Selenium 客戶端](http://selenium-release.storage.googleapis.com/2.44/selenium-java-2.44.0.zip) * [Eclipse](https://eclipse.org/downloads/packages/eclipse-ide-java-developers/lunasr1) 軟件 * Set up the JAVA_HOME and ANDROID_HOME **步驟 1)**在窗口上,右鍵單擊計算機**->** 屬性**->** 高級系統設置 ![Introduction to Selendroid](https://img.kancloud.cn/88/be/88be93b40f6e692e0e60b2582a349dd6_456x217.png "Introduction to Selendroid") **步驟 2)在**系統屬性窗口顯示中,選擇選項卡高級**->** 環境變量 ![Introduction to Selendroid](https://img.kancloud.cn/50/c3/50c33ea005b38d69a5ddabb07112770a_426x474.png "Introduction to Selendroid") **步驟 3)**在“環境”窗口顯示中,單擊“新建”。**->** 輸入變量 ANDROID_HOME,如下所示 ![Introduction to Selendroid](https://img.kancloud.cn/e7/bb/e7bb136d34ea9e4caf6b8bd586b59072_426x474.png "Introduction to Selendroid") 變量值是您已經安裝的 android-sdks 的路徑。 查找系統變量路徑**->** 編輯**->** 在當前行之后添加以下行 ![Introduction to Selendroid](https://img.kancloud.cn/45/e3/45e3b0750b4f4404a2df4e2fc1791d99_500x43.png "Introduction to Selendroid") ![Introduction to Selendroid](https://img.kancloud.cn/3c/bc/3cbc20e724737953368d0f8993b4180c_394x436.png "Introduction to Selendroid") 與 ANDROID_HOME 類似,添加新變量 JAVA_HOME,其值如下 ![Introduction to Selendroid](https://img.kancloud.cn/de/50/de50bd66712a9273d3e09ca073eca3b1_357x153.png "Introduction to Selendroid") 該值是 Java JDK 安裝的路徑 步驟 4)重新啟動電腦**->** 完成 ## 如何啟動 Selendroid ***步驟 1)在測試中獲取應用程序*** 您可以使用現有的 Selendroid 測試應用程序來檢查 Selendroid 的工作方式([將](http://search.maven.org/remotecontent?filepath=io/selendroid/selendroid-test-app/0.12.0/selendroid-test-app-0.12.0.apk)鏈接到被測試的示例應用程序) 下載完成后,將此 APK 和上面的 [Selendroid 獨立 jar](https://github.com/selendroid/selendroid/releases/download/0.11.0/selendroid-standalone-0.11.0-with-dependencies.jar) 文件復制到名為“ **Guru99”** 的文件夾中 ***步驟 2)啟動 Selendroid*** 在 Windows &上打開終端,導航到在步驟 1 中創建的文件夾 Guru99。 運行以下命令 ![Introduction to Selendroid](https://img.kancloud.cn/f7/8f/f78f7e554f796bd47811b29781b064ec_575x27.png "Introduction to Selendroid") 輸出將顯示如下 ![Introduction to Selendroid](https://img.kancloud.cn/e2/a9/e2a90a4b7b1a838b419afd82ef8e698f_698x296.png "Introduction to Selendroid") 運行此命令后,Selendroid 獨立 HTTP 服務器將啟動! 該服務器的默認端口號是 4444。將自動掃描和識別所有硬件設備以及 Android 虛擬設備。 Selendroid 將識別 Android 目標版本和設備屏幕尺寸。 要檢查 Android 目標版本以及設備信息,可以在瀏覽器中啟動以下 URL: [http:// localhost:4444 / wd / hub / status](http://localhost:4444/wd/hub/status) 。 ![Introduction to Selendroid](https://img.kancloud.cn/1a/e0/1ae0f6d2df46f6e13fc1c34d684a1c00_1870x152.png "Introduction to Selendroid") ## Selendroid 基本命令 本節介紹一些基本的 Selendroid-Standalone 命令行。 您可以使用它們來設置 Selendroid 測試環境 1. Setting port of Selendroid Selendroid 的默認端口是 4444。但是您可以通過在命令中添加參數以啟動 Selendroid 來更改為其他端口。 參數:-port *[端口號]* 例如: ![Introduction to Selendroid](https://img.kancloud.cn/47/91/4791f51ad9e4381592337e2d42417c31_620x27.png "Introduction to Selendroid") 在上面的命令中,5555 是新端口。 因此,用于檢查 Android 目標版本的 URL 更改為: [http:// localhost:5555 / wd / hub / status](http://localhost:5555/wd/hub/status) 1. Specify the location of the application under test (Binary APK file). Selendroid often required the absolute path for this file 參數:-app *[文件路徑]* For example: ![Introduction to Selendroid](https://img.kancloud.cn/c6/78/c67871f18d3b4100549273d96e18be74_620x42.png "Introduction to Selendroid") 在上面的命令中,Selendroid 自動在“ C:\ Guru99App.apk”中找到二進制文件,以獲取被測應用程序的信息。 檢查 URL [http:// localhost:4444 / wd / hub / status](http://localhost:4444/wd/hub/status) ,您將看到此信息 ![Introduction to Selendroid](https://img.kancloud.cn/ba/73/ba730f5ab8f90c6fee944b698cac2de3_859x175.png "Introduction to Selendroid") 2. Change the port the Selendroid uses to communicate with instrumentation server. Selendroid uses the port 8080 as the default 參數:-selendroidServerPort *[端口號]* 例 ![Introduction to Selendroid](https://img.kancloud.cn/0a/d1/0ad1046ab265e54a8b8366499169afce_623x42.png "Introduction to Selendroid") 端口現在更改為 9000 3. Change the timeout to start emulators. The unit is milliseconds. 參數:-timeoutEmulatorStart 默認情況下,Selendroid 將等待 300,000 毫秒,直到模擬器啟動。 您可以通過命令更改為新的超時時間(200,000 ms) ![Introduction to Selendroid](https://img.kancloud.cn/1a/95/1a951ce1591ef30440ec4e8cc5251053_623x45.png "Introduction to Selendroid") 這段時間過后,如果仿真器無法啟動,則 Selendroid 將拋出異常錯誤(尋找設備/仿真器時發生錯誤。),然后停止運行 4. When you start the Selendroid command on terminal, you will see a log printed out on the screen. You can change the type of log you see by adding the following parameter 參數:-logLevel [*日志類型*] 日志級別值為 ERROR,WARNING,INFO,DEBUG 和 VERBOSE。 默認值:ERROR。 例如,將 Selendroid 設置為僅打印警告日志,則可以使用此命令 ![Introduction to Selendroid](https://img.kancloud.cn/c2/ef/c2effc43f54ae44aa4377e833da49701_623x42.png "Introduction to Selendroid") Selendroid 僅打印警告日志 ## 使用 Selendroid 開始您的第一次測試 本節是使用 Selendroid 創建第一個測試腳本的分步指南 假設我們有一個測試名稱為 Guru99App 的 Android 應用程序。 該應用程序包括一個文本字段和一個名為“顯示文本”的按鈕。 [在此處下載 APK](https://drive.google.com/uc?export=download&id=0B_vqvT0ovzHcWFpYeVN4Tmlwckk) ![Introduction to Selendroid](https://img.kancloud.cn/14/89/14899c4193f9f8d86a5e61092ca8e997_590x376.png "Introduction to Selendroid") 我們需要使用 Selendroid 執行以下[測試用例](/test-case.html) | **測試用例** | **條件** | **預期輸出:** | | 1. 啟動應用程序 2. 在文本字段 3. 中輸入文本“ **Guru99 Test** ”按下“顯示文本”按鈕 | 受測應用程序的二進制文件可用設備已連接到 PC | 文本“此處顯示文本”更改為文本哪個用戶在文本字段中輸入 | **步驟 1)**在 Eclipse 中創建一個 Java 項目 **步驟 2)**在日食環境中添加硒和 Selendroid jar 文件 右鍵單擊 Guru99Test 項目**->** 構建路徑**->** 添加外部檔案 ![Introduction to Selendroid](https://img.kancloud.cn/66/bb/66bb01d665cf098d6a9312dbd04f7993_639x416.png "Introduction to Selendroid") 導航到存儲 jar 文件的文件夾 應該添加 3 個 jar 文件 * selendroid-client-0.10.0.jar:Selendroid Java 客戶端庫 * selendroid-standalone-0.11.0-with-dependencies:Selendroid 獨立服務器庫 * selenium-java-2.40.0.jar:Selenium Web 驅動程序庫 全選**->** 選擇“打開”以將 jar 文件添加到項目中 ![Introduction to Selendroid](https://img.kancloud.cn/6f/09/6f09375c9372d6df461009f90eb91ae2_640x434.png "Introduction to Selendroid") **步驟 3)**添加上述庫之后,這些庫將被添加到測試項目的參考庫中。 測試人員可以使用這些庫的 API 來開發測試程序 創建程序包“ com.guru.test”并添加如下所示的 java 文件“ Guru99Test.java” 右鍵單擊 Guru99Test **->** 新**->** 程序包 ![Introduction to Selendroid](https://img.kancloud.cn/25/9e/259e6746ea44df9222d89fda4b0242d9_697x149.png "Introduction to Selendroid") 在“新建 Java 包”對話框中的“名稱”字段中鍵入 com.guru.test,然后單擊“完成”。 ![Introduction to Selendroid](https://img.kancloud.cn/75/eb/75ebf4017aa4aca4b6a9065e335e5b23_525x500.png "Introduction to Selendroid") Eclipse 將在源代碼結構中創建類似這樣的列表文件夾和子文件夾 ![Introduction to Selendroid](https://img.kancloud.cn/cd/87/cd872e9c31e4ba4dfd4f7c8636a33bc0_131x150.png "Introduction to Selendroid") **步驟 4)**為 Eclipse 安裝 [TestNG](http://testng.org/doc/download.html) 在 Eclipse 中,幫助**->** 安裝新軟件,在“安裝”對話框中,單擊“添加”并輸入以下內容 * 名稱:TestNG * 位置: [http://selendroid.io/](http://selendroid.io/) 按確定**->** 接下來安裝 TestNG ![Introduction to Selendroid](https://img.kancloud.cn/d2/45/d2459b0476d1ffb163c044457c3cae22_1261x681.png "Introduction to Selendroid") **步驟 5)**將 Guru99App.apk 復制到 Test App 的文件夾中 ![Introduction to Selendroid](https://img.kancloud.cn/b7/d7/b7d74c305ba8e2449bf5b0c9a23ed68a_554x187.png "Introduction to Selendroid") **步驟 6)**獲取被測應用程序的 ID。 假設我們有一個 APK 文件名為 Guru99App.apk。 按照上一節中描述的步驟,在終端上執行命令 ![Introduction to Selendroid](https://img.kancloud.cn/ea/5c/ea5c53b28c41528c42fd05eecc3d0b5e_500x42.png "Introduction to Selendroid") 在瀏覽器中打開以下鏈接 [http:// localhost:4444 / wd / hub / status](http://localhost:4444/wd/hub/status) 。 顯示設備信息,復制 appId 值“ com.guru99app:1.0” ![Introduction to Selendroid](https://img.kancloud.cn/57/36/57364d2dadc686f7341631c5224859ed_869x163.png "Introduction to Selendroid") **步驟 7)**打開文件 Guru99Test.java(在示例代碼中)并進行如下更改 ![Introduction to Selendroid](https://img.kancloud.cn/57/d5/57d5ae54f4efc8ab03ff131ae3dcdf1a_430x147.png "Introduction to Selendroid") 要使用 Selendroid 創建新的測試會話,您必須以 *com.guru99app:1.0* 格式提供應用 ID。 該應用程序 ID 可以在步驟 6 中進行標識。如果您未將應用程序 ID 設置為與 Android 設備匹配,則測試會話將引發錯誤并且無法啟動。 初始化找到的設備后,Selendroid 創建一個自定義的 selendroid 服務器,并在其上安裝 Selendroid 服務器 Selendroid 還將安裝被測應用程序,并在設備上啟動 selendroid-server 成功初始化測試會話后,將在設備上開始執行 test 命令。 (例如輸入文本,請按按鈕...)。 如果測試追加了測試會話,則仿真器將自動停止 **步驟 8)**開始新的測試會話 在終端上使用以下命令啟動 Selendroid 服務器,如步驟 6 所示 ![Introduction to Selendroid](https://img.kancloud.cn/12/20/1220bb3f9566489a8b939343185b2464_500x42.png "Introduction to Selendroid") Selendroid Server 啟動后,在 Eclipse 上打開示例測試項目 Guru99test,雙擊文件 77- **->** 在文件 Guru99Test.java 的第 77 行設置一個斷點。 ![Introduction to Selendroid](https://img.kancloud.cn/c5/10/c5107d2dba50ea862342906c889e929d_458x96.png "Introduction to Selendroid") 通過右鍵單擊 Guru99Test 項目**->** 調試為**->** [Testng](/all-about-testng-and-selenium.html) 測試,開始測試會話。 測試會話將開始,如下所示 ![Introduction to Selendroid](https://img.kancloud.cn/7d/5b/7d5b9c64259b6b198f45381070e62fa0_944x636.png "Introduction to Selendroid") **步驟 9)**獲取被測應用程序的 GUI 元素的 ID 測試會話成功啟動后,打開瀏覽器,導航至 URL [http:// localhost:4444 / inspector](http://localhost:4444/inspector) 您將看到被測應用程序如下所示啟動 ![Introduction to Selendroid](https://img.kancloud.cn/b5/5c/b55cc078ba9b4227d08f60702bf73e2b_931x534.png "Introduction to Selendroid") 將鼠標懸停在 AUT 的每個 UI 元素(按鈕,文本字段,文本標簽)上,每個元素的 ID 都會在右窗格中突出顯示 ![Introduction to Selendroid](https://img.kancloud.cn/f0/7c/f07c11b420ee9612f39e539f7f36c7de_500x336.png "Introduction to Selendroid") 完成此步驟后,您可以獲得上面每個 UI 元素的 ID * 按鈕顯示文本 ID:“ **btnShow** ” * 文本字段 ID:“ **edtText** ” * 標簽文字 ID:“ **txtView** ” 這些 ID 將在下一步中使用 **步驟 10)**如下輸入測試程序 使用 Selendroid 的測試程序包括 3 個部分 **設置測試:** 以下是設置測試的代碼,它將設置測試會話的條件。如果發生錯誤,Selendroid 將引發異常并停止測試應用程序。 該代碼包含注釋以解釋每個語句。 ``` package com.guru.test; ?import io.selendroid.SelendroidCapabilities; import io.selendroid.SelendroidConfiguration; import io.selendroid.SelendroidDriver; import io.selendroid.SelendroidLauncher; import io.selendroid.device.DeviceTargetPlatform; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.testng.Assert; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; ?/** * @author Guru99 Test App using Selendroid * Application under test: Guru99App * */ public class Guru99Test { ?????//Declare web driver variable ????private WebDriver driver; ????/** ???? * Setup the environment before testing ???? * @throws Exception ???? */ ????@BeforeSuite ????public void setUp() throws Exception { ????????//Start selendroid-standalone during test ????????SelendroidConfiguration config = new SelendroidConfiguration(); ??????// Add the selendroid-test-app to the standalone server ????????config.addSupportedApp("Guru99App.apk"); ????????//start the standalone server ????????SelendroidLauncher selendroidServer = new SelendroidLauncher(config); ????????selendroidServer.launchSelendroid(); ???????// Create the selendroid capabilities ????????SelendroidCapabilities capa = new SelendroidCapabilities(); ???????// Specify to use selendroid's test app ????????capa.setAut("com.guru99app:1.0"); ???????// Specify to use the Android device API 19 ????????capa.setPlatformVersion(DeviceTargetPlatform.ANDROID19); ????????// Don't request simulator, use real device ????????capa.setEmulator(false); ????????//capa.wait(10000000); ????????// Create instance of Selendroid Driver ????????driver = new SelendroidDriver(capa); ????} ``` **執行測試** 以下是執行測試的代碼。 該代碼包含注釋 再次是測試步驟 1. 輸入文本“ Hello Guru” 2. 單擊顯示文本按鈕 3. 請稍等 4. 驗證應用程序是否在用戶輸入文本字段時顯示文本(例如,顯示文本“ Hello Guru”)。 ``` ?/** ???? * Start execute the test case ???? * 01\. Enter the text "Selendroid" to the textfield ???? * 02\. Press OK button ???? * @throws Exception ???? */ ????@Test ????public void selendroidTest() throws Exception { ????????// Print the log ????????System.out.print("Start executing test"); ????????// Find the input text field on screen ????????// The id of this text field was get from step 9 ????????WebElement inputField = driver.findElement(By.id("edtText")); ????????// Verify that the text field enabled so user can enter text ????????Assert.assertEquals("true", inputField.getAttribute("enabled")); ????????// Enter a text to text field ????????inputField.sendKeys("Hello Guru");???????? ?????????// click Show Text button ????????// The id of this button was get from step 9 ????????WebElement button = driver.findElement(By.id("btnShow")); ????????button.click(); ????????// Delay time to take effect ????????Thread.sleep(5000); ????????//Find the label "Text Show Here" on screen ????????// The id of this label was get from step 9 ????????WebElement txtView = driver.findElement(By.id("txtView")); ????????//Get the text display on screen ????????String expected = txtView.getText(); // Verify that the text which user enter on text field is same as text display on screen ????????Assert.assertEquals(expected, inputField.getText());???????? ?????} ``` **完成測試** 以下代碼將通過停止 Selendroid 驅動程序來完成測試。 ``` ?/** ???? * Stop the Selendroid driver ???? * ???? */ ????@AfterSuite ????public void tearDown() { ????????driver.quit(); ????} ``` 您可以在本文包含的示例代碼中查看詳細信息。 **步驟 10)**通過 USB 電纜將 Android 設備連接到 PC。 觀察要點- * 請確保設備未配置屏幕鎖定。 * 設備必須通過 USB 插入運行 *selendroid-standalone* 組件的計算機。 * 設備應至少安裝 Android Target 版本 API 10 **步驟 11)**運行 Test App:右鍵單擊 Guru99test **->** 以**->** TestNG 測試運行 ![Introduction to Selendroid](https://img.kancloud.cn/aa/5d/aa5d303cf57fce8fc0e69e34e98a1cad_720x582.png "Introduction to Selendroid") **步驟 10)**腳本開始如下執行 ![Introduction to Selendroid](https://img.kancloud.cn/e4/55/e45577a36b11edcf76e4e2bcce9fc263_600x247.png "Introduction to Selendroid") **步驟 12)**測試完成執行后,TestNG 自動生成測試報告,如下所示 ![Introduction to Selendroid](https://img.kancloud.cn/8c/94/8c940f8df72c42dba43aabb0b3c54437_839x279.png "Introduction to Selendroid") ![Introduction to Selendroid](https://img.kancloud.cn/60/e4/60e49d8b8ca54952acd202e723b4175e_1225x372.png "Introduction to Selendroid") 做得好,您現在已完成測試。 摘要 ## 摘要 * Selendroid 是用于測試 Android 本機應用程序,混合應用程序以及 Web 應用程序的功能非常強大的工具。 * 它可以在真實設備以及模擬器上使用。 * 它還允許您通過在多臺設備上運行測試來并行運行測試。 * 整個 Selendroid 套件包含四個組件: * Web 驅動程序客戶端, * Selendroid-Server, * Android 驅動程序應用 * Selendroid 獨立 * 要使用 Selendroid,您需要安裝 Java JDK,Android SDK 和 Eclipse。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看