• 我也想知道怎么同时控制两台设备,求高人指点

  • 我也是新手,用的uiautonator,里面的id也会报错,同请教

  • @young 全部按要求配置完成,运行android_contact.py报如下错误,请大侠帮忙看看?谢谢!
    C:\Users\cylboy>python D:\test\android_contact.py
    Traceback (most recent call last):
    File "D:\test\android_contact.py", line 17, in
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
    ine 72, in init
    self.start_session(desired_capabilities, browser_profile)
    File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
    ine 115, in start_session
    'desiredCapabilities': desired_capabilities,
    File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
    ine 164, in execute
    response = self.command_executor.execute(driver_command, params)
    File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
    n.py", line 347, in execute
    return self._request(command_info[0], url, body=data)
    File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
    n.py", line 429, in _request
    body = data.decode('utf-8').replace('\x00', '').strip()
    File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
    UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 193: invalid
    start byte

  • @mingyuwang 谢谢这位朋友,已经解决,确实是环境变量没有配置。

  • python android_contact.py的代码如下:
    import os
    from selenium import webdriver
    PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(file), p)
    )

    desired_caps = {}
    desired_caps['device'] = 'android'#android selendroid
    desired_caps['browserName'] = ''
    desired_caps['version'] = '4.1.2'
    desired_caps['app'] = PATH('D:\test\ContactManager.apk')
    desired_caps['app-package'] = 'com.example.android.contactmanager'
    desired_caps['app-activity'] = '.ContactManager'
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

    el = driver.find_element_by_name("Add Contact")
    el.click()

    textfields = driver.find_elements_by_tag_name("textfield")
    textfields[0].send_keys("My Name")
    textfields[2].send_keys("someone@somewhere.com")

    driver.find_element_by_name("Save").click()
    driver.quit()

  • @young 最后一步运行CMD,进入python目录,输入命令python android_contact.py 此时会自动安装apk并完成相应的添加联系人的操作
    我提示报错,请大侠帮忙看看是为何?
    C:\Python27\Scripts>python C:\Python27\Scripts\android_contact.py Traceback (most recent call last): File "C:\Python27\Scripts\android_contact.py", line 17, in driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 72, in init self.start_session(desired_capabilities, browser_profile) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 115, in start_session 'desiredCapabilities': desired_capabilities, File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 164, in execute response = self.command_executor.execute(driver_command, params) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 347, in execute return self._request(command_info[0], url, body=data) File "C:\Python27\lib\site packages\selenium\webdriver\remote\remote_connection.py", line 429, in _request body = data.decode('utf-8').replace('\x00', '').strip() File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 193: invalid start byte

  • @lihuazhang 目录结构:D:\test\appium-0.17.6里面就是源码文件了。
    我采用http://testerhome.com/topics/657 帖子中的方法appium安装成功了 ,但是输入appium-doctor,
    提示C:\Users\cylboy>appium-doctor'appium-doctor' 不是内部或外部命令,也不是可运行的程序或批处理文件。
    请大侠看看是啥原因?感谢!

  • 太感谢了,用楼主提供的方法在windows下appium安装成功。但是输入appium-doctor,提示
    C:\Users\cylboy>appium-doctor'appium-doctor' 不是内部或外部命令,也不是可运行的程序或批处理文件。
    请大侠看看是啥原因?感谢!

  • @lihuazhang step 2. appium-0.17.6就是下载下来的源码,解压到目录appium-0.17.6,然后在cmd分别运行以下两个命令:
    npm config set registry=http://registry.npmjs.org
    npm install -g appium-0.17.6
    截图就是运行命令后的报错呢

  • @lihuazhang 下载了也解压了,但是感觉npm还是到网上去找Appium,请教下大侠是为何?