Java-Eclipse-WebDriver:触摸和滚动实现 - 自动化测试



如何使用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);
}

来源

最新更新