切换 context 报错,有么有解决方法。
contexts = driver.contextsprint(contexts)
print(contexts)
driver.switch_to.context(contexts)
now = driver.current_context
print(now)报错信息:
Traceback (most recent call last):
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 211, in <module>
singlesession=args.single_session)
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 205, in main
debug_main(addr, name, kind, *extra, **kwargs)
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 30, in debug_main
run_file(address, name, *extra, **kwargs)
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 64, in run_file
run(argv, addr, **kwargs)
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 125, in _run
_pydevd.main()
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1752, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec
pydev_imports.execfile(file, globals, locals)# execute the script
File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\_pydev_imps\_pydev_execfile.py", line 25, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "c:\Program Files\ETC\ETC_UI\ETC.py", line 53, in <module>
driver.switch_to.context(contexts)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\appium\webdriver\switch_to.py", line 31, in context
self._driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {'name': context_name})
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 472, in execute
return self._request(command_info, url, body=data)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 534, in _request
resp = opener.open(request, timeout=self._timeout)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 526, in open
response = self._open(req, data)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 544, in _open
'_open', req)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 1346, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 1321, in do_open
r = h.getresponse()
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1331, in getresponse
response.begin()
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
Press any key to continue . . .Appium:
--> POST /wd/hub/session/8c961ae2-8333-4e71-bc0c-795dda358356/context
{"name":"WEBVIEW_unknown","sessionId":"8c961ae2-8333-4e71-bc0c-795dda358356"}
Calling AppiumDriver.setContext() with args: ["WEBVIEW_unknown","8c961ae2-8333-4e71-bc0c-795dda358356"]
Getting a list of available webviews
Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell cat /proc/net/unix'
WEBVIEW_9697 mapped to pid 9697
Getting process name for webview
Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell ps'
WEBVIEW_9714 mapped to pid 9714
Getting process name for webview
Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell ps'
Returning process name: 'unknown'
Returning process name: 'unknown'
Found webviews: ["WEBVIEW_unknown","WEBVIEW_unknown"]
Available contexts: ["NATIVE_APP","WEBVIEW_unknown"]
Connecting to chrome-backed webview context 'WEBVIEW_unknown'
A port was not given, using random port: 8000
Changed state to 'starting'
The following Chromedriver executables were found:
C:/Users/Penn/AppData/Roaming/npm/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe (minimum Chrome version '57.0.2987')
Getting package info for 'com.google.android.webview'
Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell dumpsys package com.google.android.webview'
Found Chrome bundle 'com.google.android.webview' version '62.0.3202'
Found 1 Chromedriver executable capable of automating Chrome '62.0.3202'.
Choosing the most recent, 'C:/Users/Penn/AppData/Roaming/npm/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe'.
If a specific version is required, specify it with the `chromedriverExecutable`desired capability.
Set chromedriver binary as: C:/Users/Penn/AppData/Roaming/npm/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe
Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"8000 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT
%b=="" TASKKILL /F /PID %a))
No old chromedrivers seemed to exist
Cleaning any old adb forwarded port socket connections
List forwarding ports
Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 forward --list'
Spawning chromedriver with: C:/Users/Penn/AppData/Roaming/npm/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe --url-base=wd/hub --port=8000 --adb-port=5037 --verbose
Chromedriver version: '2.29.461591'
Proxying to with no body
Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"10.0.17134\"}}}"
Proxying to with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"TCJRYLG6INQSKRP7"}}}
Got response with status 200: {"sessionId":"e4fe0100c0e99ef53c9a1beecb61e15f","status":100,"value":{"message":"chrome not reachable\n(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.17134 x86_64)"}}
Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.17134 x86_64))
at Object.wrappedLogger.errorAndThrow (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\appium-support\lib\logging.js:78:13)
at Chromedriver.callee$2$0$ (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:411:13)
at tryCatch (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at <anonymous>
Proxying to with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"TCJRYLG6INQSKRP7"}}}
Emitting alert message...
Emitting system alert message
Got response with status 200: {"sessionId":"83c0b5de47a260402971260f99aea264","status":100,"value":{"message":"chrome not reachable\n(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.17134 x86_64)"}}
是否切换错误内容 你这是什么工具 公爵标注一下 工具标注一下 怎么还有端口被占用的报错
页:
[1]