Java-Eclipse-WebDriver : Touch & Scroll Implementation - Automated Testing

标签 java ios eclipse selenium

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

Source

关于Java-Eclipse-WebDriver : Touch & Scroll Implementation - Automated Testing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23107340/

相关文章:

java - 每当在文件中更新时,Spring 属性文件加载程序 : how to update properties at runtime,?

java - 更改 Jasper Reports 列的大小/位置

ios - Apple-app-site-association : banner displays while no file in server

eclipse - Spring Boot应用程序不会从Eclipse启动,但可以从Cygwin运行

java - eclipse中读取maven项目失败: For Input String "US"

java - 将 Javadoc 位置分配给 Eclipse 中的 maven 管理的依赖项,其中手动安装 Javadoc

java - 用 "Enter"分割字符串

java - .realm 文件中的 "Any"字段

ios - TableView :cellForRowAtIndexPath called with nil indexPath after deleting item

ios - “???”显示在 iOS 设备上的字符串中,但不是模拟器