appium 测试 hybrid 页面,当我切换到 WEBVIEW 时,通过 find_element 查找元素时报错,具体信息如下 (测试代码是用 ruby 语言写的)
[11] pry(main)> available_contexts
[
[0] "NATIVE_APP",
[1] "WEBVIEW_com.yydys"
]
#获取webview
[19] pry(main)> webview = available_contexts.last
"WEBVIEW_com.yydys"
#切换到webview页面
[20] pry(main)> set_context webview
nil
#查找元素
[21] pry(main)> find_element(css: "btn_share")
Selenium::WebDriver::Error::NoSuchDriverError: no such session
(Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.10.2 x86_64)
from /Users/xuyao/.rvm/gems/ruby-2.2.2/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/response.rb:70:in `assert_ok'
[22] pry(main)>
看 appium 的日志没看出什么问题
[HTTP] --> POST /wd/hub/session/d342eedb-00d4-48d3-ad4f-9ca07510f928/element {"using":"css selector","value":"btn_share"}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Proxying [POST /wd/hub/session/d342eedb-00d4-48d3-ad4f-9ca07510f928/element] to [POST http://127.0.0.1:9515/wd/hub/session/4254e694b326f16b09dc17fbf84612d9/element] with body: {"using":"css selector","va...
[JSONWP Proxy] Got response with status 200: {"sessionId":"4254e694b326f...
[JSONWP Proxy] Replacing sessionId 4254e694b326f16b09dc17fbf84612d9 with d342eedb-00d4-48d3-ad4f-9ca07510f928
[HTTP] <-- POST /wd/hub/session/d342eedb-00d4-48d3-ad4f-9ca07510f928/element 200 33 ms - 176
[HTTP] --> GET /wd/hub/status {}
[MJSONWP] Calling AppiumDriver.getStatus() with args: []
[MJSONWP] Responding to client with driver.getStatus() result: {"build":{"version":"1.5.3"...
[HTTP] <-- GET /wd/hub/status 200 31 ms - 83
有谁知道上面的问题怎么解决吗,还有如果我通过 switch_to.context(webview) 切换时,会直接报 NoMethodError: undefined method `context'的错