51Testing软件测试论坛

标题: 切换 context 报错,有么有解决方法。 [打印本页]

作者: 测试积点老人    时间: 2018-9-26 10:37
标题: 切换 context 报错,有么有解决方法。
  1. contexts = driver.contexts
  2. print(contexts[0])
  3. print(contexts[1])
  4. driver.switch_to.context(contexts[1])
  5. now = driver.current_context
  6. print(now)
复制代码
报错信息:

  1. Traceback (most recent call last):
  2.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
  3.     "__main__", mod_spec)
  4.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
  5.     exec(code, run_globals)
  6.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 211, in <module>
  7.     singlesession=args.single_session)
  8.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\__main__.py", line 205, in main
  9.     debug_main(addr, name, kind, *extra, **kwargs)
  10.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 30, in debug_main
  11.     run_file(address, name, *extra, **kwargs)
  12.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 64, in run_file
  13.     run(argv, addr, **kwargs)
  14.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_local.py", line 125, in _run
  15.     _pydevd.main()
  16.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1752, in main
  17.     globals = debugger.run(setup['file'], None, None, is_module)
  18.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1099, in run
  19.     return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  20.   File "c:\Users\Penn\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd\ptvsd\_vendored\pydevd\pydevd.py", line 1106, in _exec
  21.     pydev_imports.execfile(file, globals, locals)  # execute the script
  22.   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
  23.     exec(compile(contents+"\n", file, 'exec'), glob, loc)
  24.   File "c:\Program Files\ETC\ETC_UI\ETC.py", line 53, in <module>
  25.     driver.switch_to.context(contexts[1])
  26.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\appium\webdriver\switch_to.py", line 31, in context
  27.     self._driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {'name': context_name})
  28.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
  29.     response = self.command_executor.execute(driver_command, params)
  30.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 472, in execute
  31.     return self._request(command_info[0], url, body=data)
  32.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 534, in _request
  33.     resp = opener.open(request, timeout=self._timeout)
  34.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 526, in open
  35.     response = self._open(req, data)
  36.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 544, in _open
  37.     '_open', req)
  38.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 504, in _call_chain
  39.     result = func(*args)
  40.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 1346, in http_open
  41.     return self.do_open(http.client.HTTPConnection, req)
  42.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 1321, in do_open
  43.     r = h.getresponse()
  44.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1331, in getresponse
  45.     response.begin()
  46.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 297, in begin
  47.     version, status, reason = self._read_status()
  48.   File "C:\Users\Penn\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 266, in _read_status
  49.     raise RemoteDisconnected("Remote end closed connection without"
  50. http.client.RemoteDisconnected: Remote end closed connection without response
  51. Press any key to continue . . .
复制代码
Appium:


  1. [HTTP] --> POST /wd/hub/session/8c961ae2-8333-4e71-bc0c-795dda358356/context
  2. [HTTP] {"name":"WEBVIEW_unknown","sessionId":"8c961ae2-8333-4e71-bc0c-795dda358356"}
  3. [debug] [W3C] Calling AppiumDriver.setContext() with args: ["WEBVIEW_unknown","8c961ae2-8333-4e71-bc0c-795dda358356"]
  4. [debug] [AndroidDriver] Getting a list of available webviews
  5. [debug] [ADB] Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell cat /proc/net/unix'
  6. [debug] [AndroidDriver] WEBVIEW_9697 mapped to pid 9697
  7. [debug] [AndroidDriver] Getting process name for webview
  8. [debug] [ADB] Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell ps'
  9. [debug] [AndroidDriver] WEBVIEW_9714 mapped to pid 9714
  10. [debug] [AndroidDriver] Getting process name for webview
  11. [debug] [ADB] Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell ps'
  12. [debug] [AndroidDriver] Returning process name: 'unknown'
  13. [debug] [AndroidDriver] Returning process name: 'unknown'
  14. [debug] [AndroidDriver] Found webviews: ["WEBVIEW_unknown","WEBVIEW_unknown"]
  15. [debug] [AndroidDriver] Available contexts: ["NATIVE_APP","WEBVIEW_unknown"]
  16. [debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_unknown'
  17. [debug] [AndroidDriver] A port was not given, using random port: 8000
  18. [debug] [Chromedriver] Changed state to 'starting'
  19. [debug] [Chromedriver] The following Chromedriver executables were found:
  20. [debug] [Chromedriver]     C:/Users/Penn/AppData/Roaming/npm/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe (minimum Chrome version '57.0.2987')
  21. [debug] [ADB] Getting package info for 'com.google.android.webview'
  22. [debug] [ADB] Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 shell dumpsys package com.google.android.webview'
  23. [debug] [Chromedriver] Found Chrome bundle 'com.google.android.webview' version '62.0.3202'
  24. [debug] [Chromedriver] Found 1 Chromedriver executable capable of automating Chrome '62.0.3202'.
  25. [debug] [Chromedriver] Choosing the most recent, 'C:/Users/Penn/AppData/Roaming/npm/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe'.
  26. [debug] [Chromedriver] If a specific version is required, specify it with the `chromedriverExecutable`desired capability.
  27. [Chromedriver] Set chromedriver binary as: C:/Users/Penn/AppData/Roaming/npm/node_modules/appium/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe
  28. [debug] [Chromedriver] 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
  29. %b=="" TASKKILL /F /PID %a))
  30. [Chromedriver] No old chromedrivers seemed to exist
  31. [debug] [Chromedriver] Cleaning any old adb forwarded port socket connections
  32. [debug] [ADB] List forwarding ports
  33. [debug] [ADB] Running 'C:\Program Files\android-sdk\sdk\platform-tools\adb.exe -P 5037 -s TCJRYLG6INQSKRP7 forward --list'
  34. [Chromedriver] 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
  35. [debug] [Chromedriver] Chromedriver version: '2.29.461591'
  36. [debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8000/wd/hub/status] with no body
  37. [debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"10.0.17134\"}}}"
  38. [debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"TCJRYLG6INQSKRP7"}}}
  39. [debug] [JSONWP Proxy] 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)"}}
  40. [Chromedriver] Error: Failed to start Chromedriver session: An error occurred (Original error: chrome not reachable
  41. [Chromedriver]   (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.17134 x86_64))
  42. [Chromedriver]     at Object.wrappedLogger.errorAndThrow (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\appium-support\lib\logging.js:78:13)
  43. [Chromedriver]     at Chromedriver.callee$2$0$ (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\lib\chromedriver.js:411:13)
  44. [Chromedriver]     at tryCatch (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
  45. [Chromedriver]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
  46. [Chromedriver]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
  47. [Chromedriver]     at GeneratorFunctionPrototype.invoke (C:\Users\Penn\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
  48. [Chromedriver]     at <anonymous>
  49. [debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.tencent.mm","androidUseRunningApp":true,"androidProcess":"com.tencent.mm:tools","androidDeviceSerial":"TCJRYLG6INQSKRP7"}}}
  50. [debug] [AndroidBootstrap] Emitting alert message...
  51. [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message
  52. [debug] [JSONWP Proxy] 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)"}}
复制代码




作者: qqq911    时间: 2018-9-27 10:47
是否切换错误内容
作者: libingyu135    时间: 2018-9-27 11:10
你这是什么工具
作者: 梦想家    时间: 2018-9-27 11:21
公爵标注一下
作者: 梦想家    时间: 2018-9-27 11:22
工具标注一下
作者: jingzizx    时间: 2018-9-27 13:55
怎么还有端口被占用的报错




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2