2017-02-15 21 views
0

Как и в названии, после установки возможностей я уже получил эту ошибку. Заметьте, что когда я пытаюсь перейти на веб-просмотр.Appium - Chromedriver: Ошибка: не удалось выполнить прокси-команду на удаленном сервере Исходная ошибка: 401 в Windows

Вот код после настройки возможностей: private AppiumDriver driver = null;

@Before 
public void setup() throws MalformedURLException { 
    //... 
    //setting capabilities before the following lines 
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capa); 

    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); 
} 



@Test 
public void test() throws Exception { 

    Set<String> contextNames = driver.getContextHandles(); 
    for (String contextName : contextNames) { 
     System.out.println(contextNames); //prints out something like NATIVE_APP \n WEBVIEW_1 
    } 

    driver.quit(); 
} 

Бревно, как показано ниже:

Launching Appium server with command: C:\bin\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --app C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk --app-activity com.ionicframework.welcome762668.MainActivity --app-pkg com.ionicframework.welcome762668 --platform-name Android --platform-version 22 --automation-name Appium --log-no-color 
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: {"app":"C:\\Users\\Woody\\Desktop\\welcome_ii\\welcome\\platforms\\android\\build\\outputs\\apk\\android-debug.apk","address":"127.0.0.1","logNoColors":true,"androidPackage":"com.ionicframework.welcome762668","androidActivity":"com.ionicframework.welcome762668.MainActivity","platformName":"Android","platformVersion":"22","automationName":"Appium"} 
info: Console LogLevel: debug 
info: --> POST /wd/hub/session {"desiredCapabilities":{"app":"C:\\Users\\Woody\\Desktop\\welcome_ii\\welcome\\platforms\\android\\build\\outputs\\apk\\android-debug.apk","browserName":"","app-package":"com.ionicframework.welcome762668","app-activity":"com.ionicframework.welcome762668.MainActivity","autoWebview":true,"platformName":"Android","deviceName":"HUAWEI TIT-AL00","version":"5.1","device":"Android"}} 
info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_92) 
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. : app-package, app-activity, version, device 
info: [debug] Using local app from desired caps: C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk 
info: [debug] Creating new appium session 01d0d09c-a1c7-47de-8ef3-963c1b2a9c5c 
info: Starting android appium 
info: [debug] Getting Java version 
info: Java version is: 1.8.0_92 
info: [debug] Checking whether adb is present 
info: [debug] Using adb from C:\android-sdk-windows\platform-tools\adb.exe 
info: [debug] Using fast reset? true 
info: [debug] Preparing device for session 
info: [debug] Checking whether app is actually present 
info: Retrieving device 
info: [debug] Trying to find a connected android device 
info: [debug] Getting connected devices... 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe devices 
info: [debug] 1 device(s) connected 
info: Found device AVY9KA9641316920 
info: [debug] Setting device id to AVY9KA9641316920 
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5) 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 wait-for-device 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "echo 'ready'" 
info: [debug] Starting logcat capture 
info: [debug] Getting device API level 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "getprop ro.build.version.sdk" 
info: [debug] Device is at API Level 22 
info: Device API level is: 22 
info: [debug] Extracting strings for language: default 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "getprop persist.sys.language" 
info: [debug] Current device persist.sys.language: zh 
info: [debug] java -jar "C:\bin\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk" "C:\Users\Woody\AppData\Local\Temp\com.ionicframework.welcome762668" zh 
info: [debug] No strings.xml for language 'zh', getting default strings.xml 
info: [debug] java -jar "C:\bin\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk" "C:\Users\Woody\AppData\Local\Temp\com.ionicframework.welcome762668" 
info: [debug] Reading strings from converted strings.json 
info: [debug] Setting language to default 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 push "C:\\Users\\Woody\\AppData\\Local\\Temp\\com.ionicframework.welcome762668\\strings.json" /data/local/tmp 
info: [debug] Checking whether aapt is present 
info: [debug] Using aapt from C:\android-sdk-windows\build-tools\22.0.1\aapt.exe 
info: [debug] Retrieving process from manifest. 
info: [debug] executing cmd: C:\android-sdk-windows\build-tools\22.0.1\aapt.exe dump xmltree C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk AndroidManifest.xml 
info: [debug] Set app process to: com.ionicframework.welcome762668 
info: [debug] Not uninstalling app since server not started with --full-reset 
info: [debug] Checking app cert for C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk. 
info: [debug] executing cmd: java -jar C:\bin\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk 
info: [debug] App already signed. 
info: [debug] Zip-aligning C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk 
info: [debug] Checking whether zipalign is present 
info: [debug] Using zipalign from C:\android-sdk-windows\build-tools\22.0.1\zipalign.exe 
info: [debug] Zip-aligning apk. 
info: [debug] executing cmd: C:\android-sdk-windows\build-tools\22.0.1\zipalign.exe -f 4 C:\Users\Woody\Desktop\welcome_ii\welcome\platforms\android\build\outputs\apk\android-debug.apk C:\Users\Woody\AppData\Local\Temp\117115-8564-1ckd3rn\appium.tmp 
info: [debug] MD5 for app is 3a8dd8e010c799077268eb6789591821 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "ls /data/local/tmp/3a8dd8e010c799077268eb6789591821.apk" 
info: [debug] Getting install status for com.ionicframework.welcome762668 
info: [debug] Getting device API level 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "getprop ro.build.version.sdk" 
info: [debug] Device is at API Level 22 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "pm list packages -3 com.ionicframework.welcome762668" 
info: [debug] App is installed 
info: App is already installed, resetting app 
info: [debug] Running fast reset (stop and clear) 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "am force-stop com.ionicframework.welcome762668" 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "pm clear com.ionicframework.welcome762668" 
info: [debug] Forwarding system:4724 to device:4724 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 forward tcp:4724 tcp:4724 
info: [debug] Pushing appium bootstrap to device... 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 push "C:\\bin\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/ 
info: [debug] Pushing settings apk to device... 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 install "C:\bin\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk" 
info: [debug] Pushing unlock helper app to device... 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 install "C:\bin\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: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "ps 'uiautomator'" 
info: [debug] No matching processes found 
info: [debug] Running bootstrap 
info: [debug] spawning: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.ionicframework.welcome762668 -e disableAndroidWatchers false 
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] json loading complete. 
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] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 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] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"\/data\/local\/tmp"} 
info: [debug] dataDir set to: /data/local/tmp 
info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}] 
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: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "getprop ro.build.version.sdk" 
info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false} 
info: [debug] Device is at API Level 22 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.ionicframework.welcome762668/com.ionicframework.welcome762668.MainActivity" 
info: [debug] Waiting for pkg "com.ionicframework.welcome762668" and activity "com.ionicframework.welcome762668.MainActivity" to be focused 
info: [debug] Getting focused package and activity 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "dumpsys window windows" 
info: [debug] Setting auto webview 
info: [debug] Getting a list of available webviews 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "cat /proc/net/unix" 
info: [debug] Available contexts: 
info: [debug] [] 
info: [debug] Available contexts: NATIVE_APP 
info: [debug] Retrying context switch with timeout '2000' 
info: [debug] Getting a list of available webviews 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "cat /proc/net/unix" 
info: [debug] WEBVIEW_16370 mapped to pid 16370 
info: [debug] Getting process name for webview 
info: [debug] executing cmd: C:\android-sdk-windows\platform-tools\adb.exe -s AVY9KA9641316920 shell "ps" 
info: [debug] Parsed pid: 16370 pkg: com.ionicframework.welcome762668 
info: [debug] from: u0_a400,16370,349,3197944,118084,ffffffff,00000000,S,com.ionicframework.welcome762668 
info: [debug] returning process name: com.ionicframework.welcome762668 
info: [debug] Available contexts: NATIVE_APP 
info: [debug] ["WEBVIEW_com.ionicframework.welcome762668"] 
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.ionicframework.welcome762668 
info: [debug] Connecting to chrome-backed webview 
info: Chromedriver: Changed state to 'starting' 
info: Chromedriver: Set chromedriver binary as: C:\bin\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:\bin\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 
... 
error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM 
info: Chromedriver: Changed state to 'stopped' 
warn: Chromedriver for context WEBVIEW_com.ionicframework.welcome762668 stopped unexpectedly 
warn: Chromedriver quit unexpectedly, but it wasn't the active context, ignoring 
error: Chromedriver: Error: Could not proxy command to remote server. Original error: 401 
... 
    at JWProxy.proxy$ (lib/proxy.js:109:13) 
    at tryCatch (C:\bin\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:67:40) 
... 
[Error: Could not proxy command to remote server. Original error: 401 - 
... 
    at JWProxy.proxy$ (lib/proxy.js:109:13) 
... 
{"message":"A new session could not be created. (Original error: Could not proxy command to remote server. Original error: 401 - <HTML><HEAD>\r\n<TITLE>Access 
... 
+1

Можете вложить свой код? – Vinod

+0

Я добавил коды, я использую autoWebview для возможности, все остальные возможности являются нормальными, поэтому я игнорирую его здесь. –

ответ

0

С новым UIAutomator вам не нужно переключиться на WebView. Я уже ответил на подобную проблему. Проверьте приведенную ниже ссылку.

Click Here

+0

Большое вам спасибо. Я думал, что мне нужно добавить его, так как я не запускал приложение без него раньше. Теперь, когда он работает. благодаря –