我使用appium自动化android混合应用程序,我无法切换到WEBVIEW

时间:2017-11-06 09:28:31

标签: android selenium appium

环境详情如下:

  
      
  1. 该应用程序是使用Corodova ionic
  2. 开发的   
  3. Appium版本1.4.16.1
  4.   
  5. Android版本6(牛轧糖)
  6.   

由于这个问题,我的工作完全被阻止了。任何人都可以帮助我摆脱这个问题。如果需要更多信息,请退回。

Java代码如下:

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Set;
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 sample2 {

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<MobileElement>(new 
URL("http://127.0.0.1:4723/wd/hub"), dc);
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }}
public void start(){

    Set<String> contextNames = driver.getContextHandles();
    for (Object contextName : contextNames) {
        String setContext = contextNames.toArray()[1].toString();
        System.out.println(contextName);
        driver.context(setContext);
    }
    System.out.println("Switched to webview");

}

public void close(){
    driver.quit();
}

public static void main(String[] args) {
    sample2 action = new sample2();
    action.setup();
    action.start();
    action.close();

}

}

下面是Appium Logs:

> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","browserName":"Android","platformName":"Android","version":"7.0","deviceName":"b133582d"},"requiredCapabilities":{},"capabilities":{"desiredCapabilities":{"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","browserName":"Android","platformName":"Android","version":"7.0","deviceName":"b133582d"},"requiredCapabilities":{},"alwaysMatch":{"browserName":"Android","platformName":"Android"},"firstMatch":[]}}
> info: Client User-Agent string: Apache-HttpClient/4.5.3 (Java/1.8.0_141)
> info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : version
> info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
> info: [debug] Creating new appium session 88ef3e15-3f29-473b-aa4b-6241655016ab
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.8.0_141
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from E:\path\platform-tools\adb.exe
> warn: No app capability, can't parse package/activity
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device b133582d
> info: [debug] Setting device id to b133582d
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d wait-for-device
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 24
> info: Device API level is: 24
> info: [debug] Extracting strings for language: default
> info: [debug] Apk doesn't exist locally
> info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "rm -rf /data/local/tmp/strings.json"
> info: [debug] Not uninstalling app since server not started with --full-reset
> info: [debug] Skipping install since we launched with a package instead of an app path
> info: [debug] Forwarding system:4724 to device:4724
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d forward tcp:4724 tcp:4724
> info: [debug] Pushing appium bootstrap to device...
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d 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 b133582d 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 b133582d 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 b133582d shell "ps"| grep uiautomator
> info: [debug] No matching processes found
> info: [debug] Running bootstrap
> info: [debug] spawning: E:\path\platform-tools\adb.exe -s b133582d 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] [BOOTSTRAP] [debug] Registered crash watchers.
> info: [debug] Waking up device if it's not alive
> info: [debug] Pushing command to appium work queue: ["wake",{}]
> 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] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true}
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "dumpsys window"
> 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] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false}
> info: [debug] Getting device API level
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 24
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d 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 b133582d shell "dumpsys window windows"
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d 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 88ef3e15-3f29-473b-aa4b-6241655016ab
> info: <-- POST /wd/hub/session 303 14500.746 ms - 74 
> info: --> GET /wd/hub/session/88ef3e15-3f29-473b-aa4b-6241655016ab {}
> 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","browserName":"Android","platformName":"Android","version":"7.0","deviceName":"b133582d"},"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","platformName":"Android","version":"7.0","deviceName":"b133582d"},"sessionId":"88ef3e15-3f29-473b-aa4b-6241655016ab"}
> info: <-- GET /wd/hub/session/88ef3e15-3f29-473b-aa4b-6241655016ab 200 6.920 ms - 637 {"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","browserName":"Android","platformName":"Android","version":"7.0","deviceName":"b133582d"},"appPackage":"io.ionic.starter","appActivity":"io.ionic.starter.MainActivity","platformName":"Android","version":"7.0","deviceName":"b133582d"},"sessionId":"88ef3e15-3f29-473b-aa4b-6241655016ab"}
> info: --> GET /wd/hub/session/88ef3e15-3f29-473b-aa4b-6241655016ab/contexts {}
> info: [debug] Getting a list of available webviews
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "cat /proc/net/unix"
> info: [debug] WEBVIEW_9475 mapped to pid 9475
> info: [debug] Getting process name for webview
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "ps"
> info: [debug] Parsed pid: 9475 pkg: io.ionic.starter
> info: [debug] from: u0_a252,9475,892,2683060,309148,SyS_epoll_,0000000000,S,io.ionic.starter
> info: [debug] returning process name: io.ionic.starter
> info: [debug] Available contexts: 
> info: [debug] ["WEBVIEW_io.ionic.starter"]
> info: [debug] Available contexts: NATIVE_APP,WEBVIEW_io.ionic.starter
> info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP","WEBVIEW_io.ionic.starter"],"sessionId":"88ef3e15-3f29-473b-aa4b-6241655016ab"}
> info: <-- GET /wd/hub/session/88ef3e15-3f29-473b-aa4b-6241655016ab/contexts 200 911.535 ms - 113 {"status":0,"value":["NATIVE_APP","WEBVIEW_io.ionic.starter"],"sessionId":"88ef3e15-3f29-473b-aa4b-6241655016ab"}
> info: --> POST /wd/hub/session/88ef3e15-3f29-473b-aa4b-6241655016ab/context {"name":"WEBVIEW_io.ionic.starter"}
> info: [debug] Getting a list of available webviews
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "cat /proc/net/unix"
> info: [debug] WEBVIEW_9475 mapped to pid 9475
> info: [debug] Getting process name for webview
> info: [debug] executing cmd: E:\path\platform-tools\adb.exe -s b133582d shell "ps"
> info: [debug] Parsed pid: 9475 pkg: io.ionic.starter
> info: [debug] from: u0_a252,9475,892,2711772,270076,SyS_epoll_,0000000000,S,io.ionic.starter
> info: [debug] returning process name: io.ionic.starter
> info: [debug] Available contexts: NATIVE_APP,WEBVIEW_io.ionic.starter
> info: [debug] ["WEBVIEW_io.ionic.starter"]
> info: [debug] Available contexts: NATIVE_APP,WEBVIEW_io.ionic.starter
> info: [debug] Connecting to chrome-backed webview
> info: Chromedriver: Changed state to 'starting'
> info: Chromedriver: Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
> info: Chromedriver: Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"9515 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
> info: Chromedriver: No old chromedrivers seemed to exist
> info: Chromedriver: Spawning chromedriver with: C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=9515
> info: Chromedriver: [STDOUT] Starting ChromeDriver 2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a) on port 9515
> Only local connections are allowed.
> info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
> info: JSONWP Proxy: Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"10.0\"}}}"
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"io.ionic.starter","androidUseRunningApp":true,"androidDeviceSerial":"b133582d"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"4c59842f9864cecaf4038996875fd96e","status":33,"value":{"message":"session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid 'context': {\"auxData\...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"io.ionic.starter","androidUseRunningApp":true,"androidDeviceSerial":"b133582d"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"ad8cecc823f31a7ac036937b8cb171b2","status":33,"value":{"message":"session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid 'context': {\"auxData\...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"io.ionic.starter","androidUseRunningApp":true,"androidDeviceSerial":"b133582d"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"1fbc321fdd899ed21bd39695e082df5d","status":33,"value":{"message":"session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid 'context': {\"auxData\...
> info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"io.ionic.starter","androidUseRunningApp":true,"androidDeviceSerial":"b133582d"}}}
> info: JSONWP Proxy: Got response with status 200: {"sessionId":"99abddcaed1a3c57de455b84443be8bf","status":13,"value":{"message":"unknown error: Device b133582d is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d...
> error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
> info: Chromedriver: Changed state to 'stopped'
> warn: Chromedriver for context WEBVIEW_io.ionic.starter stopped unexpectedly
> warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring
> error: Chromedriver: Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device b133582d is not online
>   (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 10.0 x86_64))
>     at JWProxy.command$ (lib/proxy.js:133:15)
>     at tryCatch (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:67:40)
>     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:315:22)
>     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:100:21)
>     at GeneratorFunctionPrototype.invoke (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:136:37)
>     at bound (domain.js:284:14)
>     at GeneratorFunctionPrototype.runBound (domain.js:297:12)
>     at run (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\es6.promise.js:89:39)
>     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\es6.promise.js:100:28
>     at flush (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\$.microtask.js:17:13)
>     at process._tickDomainCallback (node.js:381:11)
>  { [Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device b133582d is not online
>   (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 10.0 x86_64))]
>   status: 13,
>   value: { message: 'unknown error: Device b133582d is not online\n  (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 10.0 x86_64)' },
>   httpCode: 200 }
> 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 b133582d 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] Sent shutdown command, waiting for UiAutomator to stop...
> info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
> 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: 65.795
> 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

2 个答案:

答案 0 :(得分:0)

你的问题在stacktrace中非常明显:

unknown error: Device b133582d is not online

这意味着您的设备无法使用。

  1. 重新连接
  2. 在终端
  3. 中运行adb devices命令
  4. 确保您没有看到设备旁边的offline
  5. 顺便说一下,还有几个要解决的问题:

    • 如果您在Android 6上运行,那么为什么要将7个功能运行?修复它
    • 转到 Appium 1.7 ; 1.4.16服务器不适合在使用Android 6及更高版本的设备上进行测试(升级后需要添加 appWaitPackage / appWaitActivity

答案 1 :(得分:0)

无需使用driver.context(setContext);

对于Android OS 6.0及更高版本,新的UIAutomator具有识别webView元素的内置功能。确保您已更新设备中的 Android System WebView ,如果未更新,则可以通过PlayStore进行更新。

此外,您应该拥有最新版本的Android SDK包。如果没有,那么您也可以使用Android SDK Manager更新它。

使用上述配置,您的问题应该得到解决。如果没有解决,那么您应该尝试以下选项:

要查看混合中UIAutomator Developer内的WebView,请启用&#34; setWebContentsDebuggingEnabled &#34;在您的应用的Android源代码中。

如何检查应用的setWebCOntentDebuggingEnabled是否设置为true:

1.将设备连接到机器。 2.打开具有WebView的应用程序屏幕。 3.在机器上打开Chrome浏览器。 4.输入&#34; chrome:// devices /&#34;在Chrome浏览器地址栏中输入。

如果您在列表中看到您的设备并且要查看该选项,则会为您的应用启用webView调试。如果不可见则不启用。