51Testing软件测试论坛

标题: appium 无法执行swipe命令 [打印本页]

作者: wxmwindy1980    时间: 2017-4-26 15:07
标题: appium 无法执行swipe命令
本帖最后由 wxmwindy1980 于 2017-4-26 15:12 编辑

很简单的一段代码,目的就是打开手机上的今日头条,执行手势滑动,但是一直报错(错误在swipe那句,今日头条可以正常打开),找不到原因,网上查了半天也没有类似的错误。求救各位同行,不胜感激!
环境
appium 1.4.16
java "1.8.0_31"
python 3.5.3

代码
#-*-coding:utf8-*-
from appium import webdriver
from time import sleep

device='612QFCPR225ZS'
pack='com.ss.android.article.news'
activity='com.ss.android.article.news.activity.SplashActivity'
PATH = lambda p: os.path.abspath(
    os.path.join(os.path.dirname(__file__), p)
)

desired_caps={}
desired_caps['device'] = 'android'
desired_caps['platformName']='Android'
desired_caps['browserName']=''
desired_caps['Version']='6.0.1'
desired_caps['deviceName']=device
#desired_caps['app']=PATH('D:\\jr.apk')
desired_caps['appPackage'] = pack
desired_caps['appActivity'] = activity
driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)

'''while 1:
    if driver.current_activity=='.activity.MainActivity':
        print ("1")
        break
'''

driver.swipe(1035,835,1035,586,1000)

driver.quit()


错误:
Traceback (most recent call last):
  File "E:\学习\appium\test1.py", line 29, in <module>
    driver.swipe(1035,835,1035,586,1000)
  File "D:\Python\Python35\lib\site-packages\appium\webdriver\webdriver.py", line 264, in swipe
    action.perform()
  File "D:\Python\Python35\lib\site-packages\appium\webdriver\common\touch_action.py", line 94, in perform
    self._driver.execute(Command.TOUCH_ACTION, params)
  File "D:\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "D:\Python\Python35\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
    raise wde
  File "D:\Python\Python35\lib\site-packages\appium\webdriver\errorhandler.py", line 24, in check_response
    super(MobileErrorHandler, self).check_response(response)
  File "D:\Python\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command.




作者: wxmwindy1980    时间: 2017-4-26 15:32
自己找到问题了,swipe前加一个sleep就好了,原来是界面没打开就上滑了
作者: 梦想家    时间: 2017-4-26 17:45
厉害   超喜欢这种解决了还分享出来的 楼主
作者: 颓败WU宇    时间: 2018-5-29 17:31
我的一直报找不到swipe方法是什么问题 大神可以帮忙看看吗




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