I followed the following steps to setup Appium test environment on Windows 7/ Windows 10 on five computers but got the same error: WebDriverException: Message: The URL ‘/wb/hub/session’ did not map to a valid resource
Steps are as follows:
- Download latest node.js from official site and install it
- Download latest jdk from official site, install it and configure the system variables
- Download latest android SDK and configure system variables
- Download latest version (1.4.16.1) of Appium and install it through appium-installer.exe. Also I tried to install it by using node.js on some machines
- Check system variables by using appium-doctor to ensure all required variables are set.
- Run appium through Appium GUI or command appium --session-override
- Run my test case as follows, but I got the error that “the URL ‘/wb/hub/session’ did not map to a valid resource”
My test case is as follows:
#!/usr/bin/env python
#-- coding:utf8 --
import unittest
from appium import webdriver
class OfficialAccountHistoryTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
desired_caps = {}
desired_caps[‘platformName’] = ‘Android’
desired_caps[‘platformVersion’] = ‘4.4.4’
desired_caps[‘deviceName’] = ‘7C5922B03458’
desired_caps[‘appPackage’] = ‘com.tencent.mm’
desired_caps[‘appActivity’] = ‘com.tencent.mm.ui.LauncherUI’
desired_caps[‘unicodeKeyboard’] = True
desired_caps[‘resetKeyboard’] = True
desired_caps[‘fastReset’] = ‘false’
desired_caps[‘app’] = ‘D:/WeChat/weixin657android1040.apk’
desired_caps[‘fullReset’] = ‘false’
cls.driver = webdriver.Remote(‘http://192.168.1.108:4723/wb/hub’,desired_caps)
@classmethod
def tearDownClass(cls):
cls.driver.quit()
def test_openHistory(self):
pass
'''
el = self.driver.find_element_by_id('com.tencent.mm:id/bbs')
el.click()
el.send_keys('test')
el = self.driver.find_element_by_id('com.tencent.mm:id/bbt')
el.click()
'''
if name == ‘maim’:
suite = unittest.TestLoader().loadTestsFromTestCase(OfficialAccountHistoryTest)
unittest.TxtTestRunner(verbosity=2).run(suite)
Test case log is as follows:
C:\Python27\python.exe “C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pycharm\utrunner.py” D:\WeChat\testOfficialAccountHistory.py::OfficialAccountHistoryTest true
Testing started at 9:07 …
Error
Traceback (most recent call last):
File “D:\WeChat\testOfficialAccountHistory.py”, line 20, in setUpClass
cls.driver = webdriver.Remote(‘http://192.168.1.108:4723/wb/hub’,desired_caps)
File “C:\Python27\lib\site-packages\appium\webdriver\webdriver.py”, line 36, in init
super(WebDriver, self).init(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File “C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 98, in init
self.start_session(desired_capabilities, browser_profile)
File “C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 185, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File “C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 249, in execute
self.error_handler.check_response(response)
File “C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py”, line 164, in check_response
raise exception_class(value)
WebDriverException: Message: The URL ‘/wb/hub/session’ did not map to a valid resource
Process finished with exit code 0
Appium log is as follows:
C:\Users\liuyuanhui>appium --session-override
[Appium] Welcome to Appium v1.6.4
[Appium] Non-default server args:
[Appium] sessionOverride: true
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wb/hub/session {"{“capabilities”: {“unicodeKeyboard”: true,
“fastReset”: “false”, “deviceName”: “7C5922B03458”, “platformName”:
“Android”, “app”: “D:/WeChat/weixin657android1040.apk”, “firstMatch”: ":[
“”]}
[debug] [HTTP] No route found. Setting content type to ‘text/plain’
[HTTP] <-- POST /wb/hub/session 404 11 ms - 57
Investigations I did are as follows
- Read all answers from Google and Baidu but didn’t resolve this issue
- I am sure that no proxy is used on all my computers
- I turned fire wall and tried again, but no joy happens
- Use Python 2.7 or 3.x, but no joy happens
Anyone can give me some suggestion? My android device is Hongmi whose android version is 4.4.4