Appium 使用 python 测试官方的 demo 出错,可以帮我看下什么问题吗?

wenbing · 2016年10月19日 · 最后由 wenbing 回复于 2016年10月20日 · 1620 次阅读

1.已经运行了 appium
2.安装了 selenim-3.0 和 Python client for Appium 1.5,是用 python3.5
3.from time import sleep 提示是不是有错?

/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/wenbingbing/PycharmProjects/appiumtest/ContactsAndroidTests.py
test_add_contacts (__main__.ContactsAndroidTests) ... ERROR

======================================================================
ERROR: test_add_contacts (__main__.ContactsAndroidTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/wenbingbing/PycharmProjects/appiumtest/ContactsAndroidTests.py", line 23, in setUp
    self.driver = webdriver.Remote('http://127.0.0.1:4723/wb/hub', desired_caps)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/appium/webdriver/webdriver.py", line 36, in __init__
    super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 163, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: The URL '/wb/hub/session' did not map to a valid resource


----------------------------------------------------------------------
Ran 1 test in 0.017s

FAILED (errors=1)

Process finished with exit code 0
共收到 9 条回复 时间 点赞
匿名 #9 · 2016年10月19日

你的 appium 起来没有哟

#1 楼 @Tank007 已经运行起来了。

demo 是根据 python3.x 写的把

ip 不对?

在启动服务的时候,监听端口可以用 0.0.0.0 ,表示在本地所有的可用网络接口上启动,如 127.0.0.1 和 网卡的 ip 地址(同时监听)
你 py client 在连接的时候,可不能用 0.0.0.0 啊,没有这个写法,要么用 127.0.0.1,要么用真实 ip(推荐)

3.from time import sleep 这个库应该缺少了,但是不知道在哪里下载

你这句话说的简直是错误百出,time 是 python 里自带的库,置灰只是说明你代码中没有用到 sleep 这个方法,而不是说缺少这个库,而且也不需要另外去下载啊。

#5 楼 @among29 学习了,谢谢您的解答

#6 楼 @CwXwWw 学习了,谢谢您的解答,之前都是用 java 来写,大家都说 python 是用起来更轻巧,所以也是边用边学这样。

#3 楼 @jojotester 是不是要是用 python3.5 的版本才行呢?

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