如何使用Java编程语言在Eclipse中实现触摸和滑动/滚动的方法?

基本上,我必须找到一个特定的元素(在我的情况下,是我要触摸和滚动的滑块)并通过上下滑动来更改值。

谢谢!

最佳答案

IPhoneDriver不为触摸事件提供开箱即用的支持,但是您仍然可以使用jQuery来实现

/**
* Simulate the swipe action. This will swipe from right to left from the position of the element
* @param elementToSwipe
*/
public void swipeLeft(String elementToSwipe){
String javascriptToExecute = “window.jQuery(document.elementFromPoint(“
+ getElementXPosition(elementToSwipe) + “,”
+ getElementYPosition(elementToSwipe) + “))”+SWIPELEFT;
executeScript(javascriptToExecute);
}

/**
* Simulate the swipe action. This will swipe from left to right from the position of the element
* @param elementToSwipe
*/
public void swipeRight(String elementToSwipe){
String javascriptToExecute = “window.jQuery(document.elementFromPoint(“
+ getElementXPosition(elementToSwipe) + “,”
+ getElementYPosition(elementToSwipe) + “))”+SWIPERIGHT;
executeScript(javascriptToExecute);
}


Source

09-11 22:44