51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1201|回复: 5
打印 上一主题 下一主题

[原创] 切换 context 报错,有么有解决方法。

[复制链接]
  • TA的每日心情
    擦汗
    2 小时前
  • 签到天数: 527 天

    连续签到: 4 天

    [LV.9]测试副司令

    跳转到指定楼层
    1#
    发表于 2018-9-26 10:37:17 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    1测试积点
    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)"}}
    复制代码



    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    1 小时前
  • 签到天数: 1516 天

    连续签到: 5 天

    [LV.Master]测试大本营

    2#
    发表于 2018-9-27 10:47:37 | 只看该作者
    是否切换错误内容
    回复

    使用道具 举报

  • TA的每日心情

    2020-2-2 12:43
  • 签到天数: 630 天

    连续签到: 1 天

    [LV.9]测试副司令

    3#
    发表于 2018-9-27 11:10:39 | 只看该作者
    你这是什么工具
    回复

    使用道具 举报

  • TA的每日心情

    2024-7-8 09:00
  • 签到天数: 943 天

    连续签到: 1 天

    [LV.10]测试总司令

    4#
    发表于 2018-9-27 11:21:54 | 只看该作者
    公爵标注一下
    回复

    使用道具 举报

  • TA的每日心情

    2024-7-8 09:00
  • 签到天数: 943 天

    连续签到: 1 天

    [LV.10]测试总司令

    5#
    发表于 2018-9-27 11:22:02 | 只看该作者
    工具标注一下
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    4 小时前
  • 签到天数: 2812 天

    连续签到: 5 天

    [LV.Master]测试大本营

    6#
    发表于 2018-9-27 13:55:30 | 只看该作者
    怎么还有端口被占用的报错
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-15 11:52 , Processed in 0.070703 second(s), 21 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表