当我运行下面代码试,控制台会报错,请问原因是什么:
android 虚拟机 4.4.4;
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains("WEBVIEW")){
System.out.println("123");
driver.context(contextName);
}else
{
System.out.println("no WEBVIEW");
}
}
appium1.3.4.1也会提示:
info: [debug] Available contexts:
info: [debug] ["WEBVIEW_com.xiangrikui.sixapp","WEBVIEW_com.android.browser"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.xiangrikui.sixapp,WEBVIEW_com.android.browser
info: [debug] Responding to client with success: {"status":0,"value":["NATIVE_APP","WEBVIEW_com.xiangrikui.sixapp","WEBVIEW_com.android.browser"],"sessionId":"22a8c33f-43df-424a-8762-7d20241dfc9f"}
info: <-- GET /wd/hub/session/22a8c33f-43df-424a-8762-7d20241dfc9f/contexts 200 426.509 ms - 148 {"status":0,"value":["NATIVE_APP","WEBVIEW_com.xiangrikui.sixapp","WEBVIEW_com.android.browser"],"sessionId":"22a8c33f-43df-424a-8762-7d20241dfc9f"}
info: --> POST /wd/hub/session/22a8c33f-43df-424a-8762-7d20241dfc9f/context {"name":"WEBVIEW_com.xiangrikui.sixapp"}
info: [debug] Getting a list of available webviews
info: [debug] executing cmd: D:\eclipse\sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "cat /proc/net/unix"
info: [debug] WEBVIEW_4830 mapped to pid 4830
info: [debug] Getting process name for webview
info: [debug] executing cmd: D:\eclipse\sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "ps"
info: [debug] WEBVIEW_1218 mapped to pid 1218
info: [debug] Getting process name for webview
info: [debug] executing cmd: D:\eclipse\sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "ps"
info: [debug] Parsed pid: 1218 pkg: com.android.browser
info: [debug] from: u0_a18,1218,150,693820,110724,ffffffff,b769607b,S,com.android.browser
info: [debug] returning process name: com.android.browser
info: [debug] Parsed pid: 4830 pkg: com.xiangrikui.sixapp
info: [debug] from: u0_a63,4830,150,735504,131576,ffffffff,b7695a23,S,com.xiangrikui.sixapp
info: [debug] returning process name: com.xiangrikui.sixapp
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.xiangrikui.sixapp,WEBVIEW_com.android.browser
info: [debug] ["WEBVIEW_com.android.browser","WEBVIEW_com.xiangrikui.sixapp"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.android.browser,WEBVIEW_com.xiangrikui.sixapp
info: [debug] Connecting to chrome-backed webview
info: [debug] Creating Chrome session
info: [debug] Set chromedriver binary as: C:\Users\Administrator\Desktop\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Ensuring Chromedriver exists
info: [debug] 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 %b))
info: [debug] No old chromedrivers seemed to exist
info: [debug] Spawning chromedriver with: C:\Users\Administrator\Desktop\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] [CHROMEDRIVER] Starting ChromeDriver (v2.10.267521) on port 9515
Only local connections are allowed.
info: [debug] Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session,method:POST,json:{sessionId:null,desiredCapabilities:{chromeOptions:{androidPackage:com.xiangrikui.sixapp,androidUseRunningApp:true,androidDeviceSerial:192.168.56.101:5555}}}"}
> info: [debug] [CHROMEDRIVER STDERR] [0.006][SEVERE]: Could not bind socket to 127.0.0.1:9515
info: [debug] [CHROMEDRIVER] Port not available. Exiting...
info: [debug] Chromedriver exited with code 1
info: [debug] Chromedriver exited unexpectedly
error: Chromedriver create session did not work. Status was 200 and body was {"sessionId":"87b05498cae7ab815d52f1cf9d2300d7","status":13,"value":{"message":"unknown error: Chrome version must be >= 33.0.1750.0\n (Driver info: chromedriver=2.10.267521,platform=Windows NT 6.1 x86_64)"}}
info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: Did not get session redirect from Chromedriver)","origValue":"Did not get session redirect from Chromedriver"},"sessionId":"22a8c33f-43df-424a-8762-7d20241dfc9f"}
info: <-- POST /wd/hub/session/22a8c33f-43df-424a-8762-7d20241dfc9f/context 500 882.897 ms - 280
info: --> DELETE /wd/hub/session/22a8c33f-43df-424a-8762-7d20241dfc9f {}
info: Shutting down appium session
info: [debug] Pressing the HOME button
info: [debug] executing cmd: D:\eclipse\sdk\platform-tools\adb.exe -s 192.168.56.101:5555 shell "input keyevent 3"
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stop...