如何使用 Java 编程语言在 Eclipse 中实现触摸和滑动/滚动方法?
基本上,我必须找到一个特定的元素(在我的例子中,我想要触摸和滚动的 slider )并通过上下滑动/滚动来更改值。
谢谢!
最佳答案
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);
}
关于Java-Eclipse-WebDriver : Touch & Scroll Implementation - Automated Testing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23107340/