【问题标题】:Youtube page(WebView) automation on android Chrome browserAndroid Chrome 浏览器上的 Youtube 页面(WebView)自动化
【发布时间】:2014-07-15 14:24:02
【问题描述】:

能够在 Appium 1.0.0.3 中从 android chrome 浏览器成功打开 Youtube 页面(WebView)。

伙计们,我在这里被击中了。请帮助我实现我的目标。

- I can't able to identify elements inside WebView using "uiautomatorviewer.bat"

- I can't able to switch to WebView through following code
       - driver.switch_to.context('WEBVIEW')
          one more I tried
       - driver.switch_to.context(webview)

我的目标:

场景一:

在安卓 Chrome 浏览器上打开 Youtube 页面。 选择任何视频进行播放。 点击暂停和播放。 点击全屏按钮。

场景 2:

在安卓 Chrome 浏览器上打开 URL:“http://m.youtube.com/watch?v=7-7knsP2n5w”。 点击播放按钮。

示例代码:

from appium import webdriver

desired_caps = {}
desired_caps['automationName'] = 'Appium'
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4'
desired_caps['deviceName'] = 'Nexus 7'
desired_caps['browserName'] = 'Chrome'

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

driver.get('http://m.youtube.com')

driver.switch_to.context('WEBVIEW')    # Unable to switch to webview. Getting following error.

Python 解释器错误:

Traceback (most recent call last):
File "C:\Python27\lib\bdb.py", line 400, in run
exec cmd in globals, locals
File "C:\Data\VVO\Automation\ROBOT_FRAMEWORK\AndroidTest\Appium\tmp_browser.py", line 2, in <module>
from appium import webdriver
File "build\bdist.win32\egg\appium\webdriver\switch_to.py", line 31, in context
self._driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {'name': context_name})
File "C:\Python27\lib\site-packages\selenium-2.42.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 172, in execute
self.error_handler.check_response(response)
File "build\bdist.win32\egg\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
WebDriverException: Message: 'unknown command: session/d6c14715e9f6ca685030f9f56a2b698e/context'

Appium 服务器日志:

POST /wd/hub/session/74354d82912ad3db704d67eeb04a295b/url 200 18052ms - 85b
debug: Appium request initiated at /wd/hub/session/74354d82912ad3db704d67eeb04a295b/context
debug: Request received with params:    {"sessionId":"74354d82912ad3db704d67eeb04a295b","name":"WEBVIEW"}
debug: Proxying command to 127.0.0.1:9515
info: Making http request with opts: {"url":"http://127.0.0.1:9515/wd/hub/session/74354d82912ad3db704d67eeb04a295b/
context","method":"POST","json":{"sessionId":"74354d82912ad3db704d67eeb04a295b","name":"WEBVIEW"}}
debug: Proxied response received with status 404: "unknown command:   session/74354d82912ad3db704d67eeb04a295b/context"
POST /wd/hub/session/74354d82912ad3db704d67eeb04a295b/context 404 8ms - 65b

【问题讨论】:

    标签: google-chrome webview youtube appium


    【解决方案1】:

    当你初始化你的webdriver时,url应该设置为http://0.0.0.0:9515/wd/hub/

    您在切换上下文时遇到问题,因为 Appium 没有与应用成功对话。

    尝试print driver.page_source,当它起作用时(并打印出页面 xml),其余的一切(切换上下文等)也应该起作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-28
      • 2017-06-21
      • 2011-01-20
      • 2014-12-27
      • 2014-02-20
      • 2016-11-16
      • 2011-11-15
      • 1970-01-01
      相关资源
      最近更新 更多