Appium 运行 appium 自带实例时遇到的小坑~

luckysunshine · 2014年09月11日 · 最后由 bingle 回复于 2014年12月25日 · 2056 次阅读

1.在脚本中会有:from appium import webdriver
第一次运行时可能会遇到这样的 error:No module named appium
之所以会报这样的 error 是因为没有装 client
client 下载地址 :https://github.com/appium/python-clienthttps://github.com/appium/python-clienthttps://github.com/appium/python-client
下载下来后,python setup.py install
可能在安装过程中会遇到权限问题

2.ERROR: test_scroll (main.SimpleIOSTests)

Traceback (most recent call last):
File "ios_simple.py", line 57, in test_scroll
el = self.driver.find_element_by_accessibility_id('OK')
File "build/bdist.macosx-10.9-intel/egg/appium/webdriver/webdriver.py", line 135, in find_element_by_accessibility_id
return self.find_element(by=By.ACCESSIBILITY_ID, value=id)
File "/Library/Python/2.7/site-packages/selenium-2.42.1-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 662, in find_element
{'using': by, 'value': value})['value']
File "/Library/Python/2.7/site-packages/selenium-2.42.1-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "build/bdist.macosx-10.9-intel/egg/appium/webdriver/errorhandler.py", line 29, in check_response
raise wde
NoSuchElementException: Message: u'An element could not be located on the page using the given search parameters.'
这样的 error 是因为 Python 测试代码有问题,appium 自带的代码和 server 不匹配,你可以更改一下代码中 app 的路径就 ok 了。

共收到 10 条回复 时间 点赞

#3 楼 @hjj20040849 请问现在问题解决了吗?我现在也是这样的问题,不知道怎么解决了,求教!

安装了 selenium-2.45.0-Python,sudo python setup.py install 也成功了,但是运行时还会报错呀。

mscdeMacBook-Pro:python msc$ python ios_simple.py
Traceback (most recent call last):
File "ios_simple.py", line 7, in
from appium import webdriver
ImportError: No module named appium

#3 楼 @hjj20040849 我的解决了 注释 test_ui_computation 方法的代码 虽然不是真正解决问题 但是 至少运行通过了

11楼 已删除

#3 楼 @hjj20040849 哥们,同问这个,你解决了吗

请问” 更改一下代码中 app 的路径 “指的是更改

app = os.path.join(os.path.dirname(__file__),
                           '../../apps/TestApp/build/Release-iphonesimulator',
                           'TestApp.app')

这里的吗

#4 楼 @face_south 明白了 Appium-Python-Client

No module named appium
之所以会报这样的 error 是因为没有装 client;
这个 client 指的是什么,不明白,求指教

你好,我在运行官方给的例子的时出现了这个错误,但是不知道该怎么解决,能帮个忙吗?

kevindeMacBook-Pro:python kevin$ python ios_simple.py 
test_scroll (__main__.SimpleIOSTests) ... ERROR
test_ui_computation (__main__.SimpleIOSTests) ... ERROR

======================================================================
ERROR: test_scroll (__main__.SimpleIOSTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "ios_simple.py", line 57, in test_scroll
    el = self.driver.find_element_by_accessibility_id('OK')
  File "/Library/Python/2.7/site-packages/appium/webdriver/webdriver.py", line 135, in find_element_by_accessibility_id
    return self.find_element(by=By.ACCESSIBILITY_ID, value=id)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 662, in find_element
    {'using': by, 'value': value})['value']
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 173, in execute
    self.error_handler.check_response(response)
  File "/Library/Python/2.7/site-packages/appium/webdriver/errorhandler.py", line 29, in check_response
    raise wde
NoSuchElementException: Message: An element could not be located on the page using the given search parameters.


======================================================================
ERROR: test_ui_computation (__main__.SimpleIOSTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "ios_simple.py", line 42, in test_ui_computation
    self._populate()
  File "ios_simple.py", line 32, in _populate
    els = self.driver.find_elements_by_ios_uiautomation('elements()')
  File "/Library/Python/2.7/site-packages/appium/webdriver/webdriver.py", line 101, in find_elements_by_ios_uiautomation
    return self.find_elements(by=By.IOS_UIAUTOMATION, value=uia_string)
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 677, in find_elements
    {'using': by, 'value': value})['value']
  File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 173, in execute
    self.error_handler.check_response(response)
  File "/Library/Python/2.7/site-packages/appium/webdriver/errorhandler.py", line 29, in check_response
    raise wde
WebDriverException: Message: An error occurred while executing user supplied JavaScript.


----------------------------------------------------------------------
Ran 2 tests in 23.224s

FAILED (errors=2)

#1 楼 @lihuazhang 囧 下次注意

楼主的分享是好的,但是不知道楼主发帖的时候有没有看右边的发帖规则呢?

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