51Testing软件测试论坛

标题: Appium使用python进行自动化测试问题,webdriver.Remote报编码错误 [打印本页]

作者: 测试积点老人    时间: 2019-12-30 13:19
标题: Appium使用python进行自动化测试问题,webdriver.Remote报编码错误
Appium使用python进行自动化测试问题,webdriver.Remote报编码错误
为了进行app测试,我进行了appium的学习,机器是win7-64位的,环境都已经搭好,下载代码如下:
  1. #coding: utf-8

  2. import os
  3. from time import sleep
  4. from appium import webdriver


  5. # Returns abs path relative to this file and not cwd
  6. PATH = lambda p: os.path.abspath(
  7. os.path.join(os.path.dirname(__file__), p)
  8. )


  9. desired_caps = {}
  10. desired_caps['platformName'] = 'Android'
  11. desired_caps['browserName'] = ''
  12. desired_caps['platformVersion'] = '4.4.2'
  13. desired_caps['appPackage'] = 'com.njzx.lehuoli'
  14. desired_caps['appActivity'] = '.ui.activity.base.MainActivity'
  15. desired_caps['deviceName'] = 'emulator-5554'

  16. driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub/',desired_caps)

  17. el = find_element_by_accessibility_id('com.njzx.lehuoli:id/button_login')
  18. el.click()

  19. time.sleep(5)

  20. driver.quit()



  21. 运行以后报错:

  22. Traceback (most recent call last):
  23. File "E:\Workplace\app test\login_test.py", line 22, in <module>
  24. driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub/',desired_caps)
  25. File "E:\Python27\lib\site-packages\appium\webdriver\webdriver.py", line 36, in __init__
  26. super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
  27. File "E:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 90, in __init__
  28. self.start_session(desired_capabilities, browser_profile)
  29. File "E:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 177, in start_session
  30. response = self.execute(Command.NEW_SESSION, capabilities)
  31. File "E:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 234, in execute
  32. response = self.command_executor.execute(driver_command, params)
  33. File "E:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 401, in execute
  34. return self._request(command_info[0], url, body=data)
  35. File "E:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 481, in _request
  36. body = data.decode('utf-8').replace('\x00', '').strip()
  37. File "E:\Python27\lib\encodings\utf_8.py", line 16, in decode
  38. return codecs.utf_8_decode(input, errors, True)
  39. UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 193: invalid start byte
复制代码




作者: qqq911    时间: 2019-12-31 11:10
编码格式错误
作者: litingting0214    时间: 2019-12-31 12:02
查看下appium里面的日志
作者: jingzizx    时间: 2019-12-31 12:05
看报错是编码格式
作者: 你好浮戈    时间: 2019-12-31 12:37
看下手机上app的版本是否一致




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2