我使用的是5.0.2 Java-client for Appium,但我无法使用以下代码执行水平滑动:
touchAction.press(startX, startY).moveTo(endX, startY).release().perform();
我在Android上自动化一个离子应用程序。有人知道我怎么刷卡吗?
注意:我确实将上下文切换到WEBVIEW
以与应用程序交互,然后返回到NATIVE_APP
上下文以使用TouchAction
。
发布于 2017-09-07 11:37:13
我用的是“driver.swpe”,touchAction不适合我的网页应用……
Python代码:
# Screen movement is left -> right (element is hidden at the right of the screen)
# I have a list of items (all the same) and I move 1 by 1
startX = selected.size['width']
# 'Y' coordinate in this case is the middle of the element
startY = selected.location['y'] + (selected.size['height']/2)
# This will move from startX, startY, to 1, startY in a duration of 400
driver.swipe(startX , startY, 1, startY , 400)
# Screen movement is right -> left (element is hidden at the left of the screen)
driver.swipe(1, startY, startX, startY , 400)
只是为了记录..。正如我所说,对于我来说,它不适用于touchAction,而对于touchAction,它不是这样的:
driver.swipe(startX , startY, 1, startY...)
就像是
touchAction.press(startX, startY).move_to((startX*-1), 0).release().perform()
这是为了让你认为这是累积的.你move_to尊重你按的地方..。
我的意思是,你没有指定你想要移动到哪里的坐标...从原点(startX和startY)指定从这些坐标水平和垂直移动多少...
我猜在Java中会是这样的:
# You can change swipe duration to whatever value you want (Milliseconds)
# Screen movement is left -> right
driver.swipe(startX, startY, 1, startY, 400);
# Screen movement is right -> left
driver.swipe(1, startY, startX, startY, 400);
发布于 2017-09-19 23:30:11
我可以使用swipe injecting css样式:
int width = ((Long) js.executeScript("return window.innerWidth || document.body.clientWidth")).intValue();
js.executeScript("arguments[0].style.cssText = \"position: absolute; left: -"+ width+"px;\";", element);
不确定这是否正确,但对我来说是有效的。
此外,使用css转换也可以:
js.executeScript("arguments[0].style.cssText = \"position: absolute; transform: translateX(-100%)\";", element);
发布于 2017-09-23 17:21:45
我以前遇到过类似的问题,并执行了以下步骤来解决这些问题。
新的TouchAction(驱动程序).press(startX、startY).moveTo(endX、
https://stackoverflow.com/questions/46085288
复制相似问题