环境
该应用程序采用角度离子2开发。 我正在使用uiautomatorviewer,我能够识别屏幕中的所有元素。但是当我运行我的脚本时,我收到一条错误消息,说无法找到该元素。 Appium日志
info: [debug] Pushing appium bootstrap to device...
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 push "C:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
info: [debug] Pushing settings apk to device...
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
info: [debug] Pushing unlock helper app to device...
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Starting App
info: [debug] Attempting to kill all 'uiautomator' processes
info: [debug] Getting all processes with 'uiautomator'
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell "ps"| grep uiautomator
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg io.ionic.starter -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] Warning: This version of UI Automator is deprecated. New tests should be written using
info: [debug] [UIAUTOMATOR STDOUT] UI Automator 2.0 which is available as part of the Android Testing Support Library.
info: [debug] [UIAUTOMATOR STDOUT] See https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html
info: [debug] [UIAUTOMATOR STDOUT] for more details.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json...
info: [debug] Waking up device if it's not alive
info: [debug] Pushing command to appium work queue: ["wake",{}]
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell "dumpsys window"
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
info: [debug] Screen already unlocked, continuing.
info: [debug] Pushing command to appium work queue: ["getDataDir",{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data\/local\/tmp"}
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] Getting device API level
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell "getprop ro.build.version.sdk"
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false}
info: [debug] Device is at API Level 24
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.ionic.starter/io.ionic.starter.MainActivity"
info: [debug] Waiting for pkg "io.ionic.starter" and activity "io.ionic.starter.MainActivity" to be focused
info: [debug] Getting focused package and activity
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell "dumpsys window windows"
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell "getprop ro.build.version.release"
info: [debug] Device is at release version 7.0
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId 0212f982-e957-48b8-999d-033d5f62a6ce
info: <-- POST /wd/hub/session 303 17850.686 ms - 74
info: --> GET /wd/hub/session/0212f982-e957-48b8-999d-033d5f62a6ce {}
info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"7.0","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","automationName":"uiautomator2","browserName":"Android","platformName":"Android","version":"7.0","deviceName":"b133582d"},"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","automationName":"uiautomator2","platformName":"Android","version":"7.0","deviceName":"ce041714c44ebd1802"},"sessionId":"0212f982-e957-48b8-999d-033d5f62a6ce"}
info: <-- GET /wd/hub/session/0212f982-e957-48b8-999d-033d5f62a6ce 200 1.986 ms - 711 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"7.0","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","automationName":"uiautomator2","browserName":"Android","platformName":"Android","version":"7.0","deviceName":"b133582d"},"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","automationName":"uiautomator2","platformName":"Android","version":"7.0","deviceName":"ce041714c44ebd1802"},"sessionId":"0212f982-e957-48b8-999d-033d5f62a6ce"}
info: --> POST /wd/hub/session/0212f982-e957-48b8-999d-033d5f62a6ce/timeouts {"type":"implicit","ms":30000}
info: [debug] Set Android implicit wait to 30000ms
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"0212f982-e957-48b8-999d-033d5f62a6ce"}
info: <-- POST /wd/hub/session/0212f982-e957-48b8-999d-033d5f62a6ce/timeouts 200 1.988 ms - 76 {"status":0,"value":null,"sessionId":"0212f982-e957-48b8-999d-033d5f62a6ce"}
info: --> POST /wd/hub/session/0212f982-e957-48b8-999d-033d5f62a6ce/elements {"using":"class name","value":"android.widget.EditText"}
info: [debug] Waiting up to 30000ms for condition
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Waited for 8590ms so far
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Waited for 11641ms so far
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Waited for 15447ms so far
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Waited for 18506ms so far
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] Waited for 26835ms so far
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Waited for 29877ms so far
info: [debug] Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: find
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
info: [debug] [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId: multiple: true
info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] getElements selector:UiSelector[CLASS=android.widget.EditText]
info: [debug] [BOOTSTRAP] [debug] Element[] is null: (0)
info: [debug] [BOOTSTRAP] [debug] getElements tmp selector:UiSelector[CLASS=android.widget.EditText, INSTANCE=0]
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":[]}
info: [debug] Condition unmet after 32916ms. Timing out.
info: [debug] Responding to client with success: {"status":0,"value":[],"sessionId":"0212f982-e957-48b8-999d-033d5f62a6ce"}
info: <-- POST /wd/hub/session/0212f982-e957-48b8-999d-033d5f62a6ce/elements 200 32918.226 ms - 74 {"status":0,"value":[],"sessionId":"0212f982-e957-48b8-999d-033d5f62a6ce"}
info: [debug] [BOOTSTRAP] [debug] Emitting system alert message
info: [debug] Emitting alert message...
info: [debug] Didn't get a new command in 60 secs, shutting down...
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s ce041714c44ebd1802 shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 111.066
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] We shut down because no new commands came in
脚本
package Appium;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
public class Sample1 {
AppiumDriver<MobileElement> driver;
public void setup(){
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(CapabilityType.BROWSER_NAME,"Android");
dc.setCapability(CapabilityType.VERSION,"7.0");
dc.setCapability("deviceName","b133582d");
dc.setCapability("platformName", "Android");
dc.setCapability("appPackage", "io.ionic.starter");
dc.setCapability("appActivity", "io.ionic.starter.MainActivity");
try {
driver= new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), dc);
} catch (MalformedURLException e) {
e.printStackTrace();
}
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
System.out.println("Session is created");
}
public void sendtext(){
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
}
System.out.println("before");
WebDriverWait driverWait = new WebDriverWait(driver, 30);
driverWait.until(ExpectedConditions.visibilityOfElementLocated(By.className("android.widget.EditText")));
System.out.println(driver.findElement(By.className("android.widget.EditText")).getText());
System.out.println("After");
}
public static void main(String[] args) {
Sample1 sam = new Sample1();
sam.setup();
sam.sendtext();
}}