Appium appium +python IOS 模拟器,4 张引导页的时候如何从右向左滑动

daivd · 2015年07月27日 · 最后由 hardy 回复于 2017年11月14日 · 2604 次阅读
appium +python IOS 模拟器,4 张引导页的时候如何从右向左滑动, 执行的话可以执行成功,但是模拟器上来看,没什么反应,求教!~代码如下
class 省略。。
    def test_welcome(self):
        # for swiping through welcome screen
        print u"""欢迎页cases"""
        self.driver.implicitly_wait(5)
        for i in range(4):
            print u'开始执行滑动', i+1
            self.driver.swipe(start_x=333, start_y=497, end_x=50, end_y=497, duration=800)
            self.driver.implicitly_wait(15)
共收到 12 条回复 时间 点赞
daivd #11 · 2015年07月27日 Author

log is here
:null,"sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8"}
info: --> POST /wd/hub/session/1794bc16-2e4e-4342-bd10-3b3fbd661cc8/touch/perform {"sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8","actions":[{"action":"press","options":{"y":497,"x":333}},{"action":"wait","options":{"ms":1000}},{"action":"moveTo","options":{"y":497,"x":50}},{"action":"release","options":{}}]}
info: [debug] Pushing command to appium work queue: "au.dragApp(333,497,50,497,1)"
info: [debug] Sending command to instruments: au.dragApp(333,497,50,497,1)

info: [debug] [INST] 2015-07-27 07:06:04 +0000 Debug: Got new command 6 from instruments: au.dragApp(333,497,50,497,1)
info: [debug] [INST] 2015-07-27 07:06:04 +0000 Debug: evaluating au.dragApp(333,497,50,497,1)
info: [debug] [INST] 2015-07-27 07:06:04 +0000 Debug: target.dragFromToForDuration({x:"333", y:"497"}, {x:"50", y:"497"}, "1")

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.4.8","revision":"c8179bd8352d3c62d98fa58b324491230df9342a"},"isShuttingDown":false},"sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8"}
info: <-- GET /wd/hub/status 200 1.317 ms - 178 {"status":0,"value":{"build":{"version":"1.4.8","revision":"c8179bd8352d3c62d98fa58b324491230df9342a"},"isShuttingDown":false},"sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8"}

info: [debug] [INST] 2015-07-27 07:06:05 +0000 Debug: evaluation finished
info: [debug] [INST] 2015-07-27 07:06:05 +0000 Debug: responding with:
info: [debug] [INST] 2015-07-27 07:06:05 +0000 Debug: Running system command #7: /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":""}...
info: [debug] Socket data received (25 bytes)
info: [debug] Socket data being routed.
info: [debug] Got result from instruments: {"status":0,"value":""}

info: [debug] Responding to client with success: {"status":0,"value":"","sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8"}

info: <-- POST /wd/hub/session/1794bc16-2e4e-4342-bd10-3b3fbd661cc8/touch/perform 200 2218.502 ms - 74 {"status":0,"value":"","sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8"}
info: --> POST /wd/hub/session/1794bc16-2e4e-4342-bd10-3b3fbd661cc8/timeouts/implicit_wait {"sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8","ms":15000}
info: [debug] Set iOS implicit wait to 15000ms
info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8"}
info: <-- POST /wd/hub/session/1794bc16-2e4e-4342-bd10-3b3fbd661cc8/timeouts/implicit_wait 200 2.629 ms - 76 {"status":0,"value":null,"sessionId":"1794bc16-2e4e-4342-bd10-3b3fbd661cc8"}

建议你先试试直接用 UIAutomation 执行 target.dragFromToForDuration({x:"333", y:"497"}, {x:"50", y:"497"}, "1") 这段代码。

印象中 iOS 7.0+ 的 Simulator 有个在 scroll view 中进行滑动手势方面的 bug :
https://github.com/appium/appium/blob/master/docs/cn/writing-running-appium/touch-actions.cn.md

如果直接用 UIAutomation 也不行那就用真机试试,如果还是不行那就要看看是否移动的距离不够了。

#3 楼 @chenhengjie123
好的,谢谢

x,y 的值不能写死。
分辨率不一样。建议使用屏幕的比例。先获取 self.dr.get_window_size() 屏幕。然后自己算个比例。调试下就好了,这样这种分辨率都能适配了。

#6 楼 @among29 请问滑动手势的 python 代码该怎么写

我也遇到这个问题,用 scroll 解决了。

#8 楼 @nirvana
thank you

@nirvana 请问怎么解决的

我写的 self.driver.swipe(x * 6 / 7, y / 2, -1 * x / 8, y / 2, 2000)
确实模拟器是滑动了 但是它还会自己滑回去 本来我是希望把整页滑动过去的

p 回复

python scroll 的方法是怎么用呢

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