Appium app 中切换 webview 提示:AttributeError: 'WebDriver' object has no attribute 'contexts'

· 2017年06月30日 · 最后由 doladola 回复于 2020年11月24日 · 2184 次阅读

# 切换 app 到 h5
webview = driver.contexts
print webview

报错
webview = driver.contexts
AttributeError: 'WebDriver' object has no attribute 'contexts'

appium 版本 1.4.3

共收到 18 条回复 时间 点赞
#1 · 2017年06月30日 Author

新手上路 求大神帮忙解决下 谢谢

#2 · 2017年06月30日 Author

Mac 环境。python2.7 不知道具体是哪一块出了问题,希望大神帮忙解决下 跪谢

在老版本里好像是调用的方法,不是属性,所以 contexts 后加小括号试试

—— 来自 TesterHome 官方 安卓客户端

Stepthen 回复

这么晚。。

你应该贴出 appium python client 的版本,不是 appium 版本。

脚本 api 只和 appium python client 直接相关。

#6 · 2017年07月01日 Author
陈恒捷 回复

webview =driver.contexts()
print webview
driver.switch_to.context(webview[1])
这样还是报错 webview =driver.contexts()
AttributeError: 'WebDriver' object has no attribute ‘contexts'
不知道什么原因 求大神帮忙看看

#7 · 2017年07月01日 Author
陈恒捷 回复

大神 appium python client。版本怎么看啊,很久都没解决这个问题 ,可以的话 加 q515488179。帮忙解答下 跪谢

#8 · 2017年07月01日 Author
陈恒捷 回复

问题解决了 我知道自己出在哪里了 谢谢大恨

#9 · 2017年07月01日 Author
Stepthen 回复

知道自己问题出在哪里了 谢谢

回复

解决了就好~建议也附上下你的解决方法吧,说不定真的有其他人也遇到一样的问题在苦苦寻找答案呢。

PS:版本怎么看这种问题,建议先自行百度,实在无果才问,并附上自己努力过的证明。。。这种问题问出来很打击想帮你的人的热情。。。

#11 · 2017年07月03日 Author
陈恒捷 回复

我是导入包的时候出的问题,多谢大神指导

回复

我不是大神呀。。。另外,社区里请不要随便用大神这种称呼,这个称呼不少人并不喜欢。

陈恒捷 回复

我记得屏蔽了大神。。

回复

你好,我这边也遇到跟你同样的问题,导入包那里没看见有报错的提示,怎么检查呢?

'WebDriver' object has no attribute 'contexts' 我也遇到了,找不到原因~

这些人问题解决了为什么不说出来 from selenium import webdriver 中的 selenium 换成 appium 即可

龙里祁 回复

感谢

龙里祁 回复

感谢,遇到相同问题,信号看到这里,再次感谢

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册