- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 touchstart
和 touchmove
事件编写了一些 Javascript 代码。我想用 Selenium 来测试它。我刚刚发现了TouchActions具有 move
方法的类似乎正是我想要的。
我的测试是使用 RemoteWebDriver 运行的:
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
驱动程序将是 ChromeDriver
或最终是 FirefoxDriver
,而不是 AndroidDriver
。
当我尝试使用以下方式初始化操作时:
TouchActions builder = new TouchActions(remoteWebDriver);
我收到转换错误:
java.lang.ClassCastException: org.openqa.selenium.remote.RemoteWebDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
有人知道我应该做什么吗?我需要添加一项功能吗?
最佳答案
因此,为了能够做到这一点,需要首先向驱动程序添加移动功能(请参阅 Mobile Emulation ):
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Galaxy S5"); // Choose a device available in your version of chromimum
Map<String, Object> options = new HashMap<>();
options.put("mobileEmulation", mobileEmulation);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
然后,当您需要触摸操作时,您需要“增强”驱动程序,以便能够转换它:
TouchActions builder = new TouchActions(new Augmenter().augment(remoteWebDriver));
然后,从该构建器中,您可以执行 builder.down()、move()、scroll()、up()...
任何您需要的操作。
关于selenium - 如何将 Selenium TouchActions 与 RemoteWebDriver 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58339004/
我正在寻找使用最新(此时)Appium Java 客户端 6.1.0 创建 Tap/Swipe/Drag 等事件的“正确”或“最新”方式。 我在 Appium 站点( Tap using TouchA
我以前是这样做的:TouchAction t = new TouchAction(驱动程序); 但现在向我要泛型!还有一些方法已弃用,有人可以给我一个如何使用 java 在 appium 中实例化 T
我能够使用我通过触摸操作编写的滚动方法,但现在运行它时出现编译错误。我现在应该使用什么或者我可以做什么来解决编译问题? public void scrollDown() { AndroidDr
我在尝试使用滑动时遇到了错误,但它似乎已经过时了。建议使用 TouchAction(),但我不确定如何将滑动转换为 TouchAction()。 代码如下: public void obj_scrol
这里是移动自动化的新手。我正在尝试使用 Touch Action 执行以下代码来执行滑动操作以导航到第 2 页,但滑动不起作用。 AndroidDriver driver=new AndroidDri
And(/^I click OK button in popup$/) do #Appium::TouchAction.new.tap(x:0.64, y:0.57, count: 1).perf
Selenium ActionChains 模块能够移动到具有偏移量的元素(提供 x 和 y 坐标,如下所示):ActionChains(浏览器).move_to_element_with_offse
我正在使用多线程在多个android设备上运行并行测试。代码可以在没有多线程的情况下正常运行。我认为Appium:TouchAction存在一些同步问题。 这是我的代码: require 't
我有一个坐标字符串数组,其中数组中的每个字符串都分配给一个 int String[] A = {"217, 423", "557, 408", "927, 393"}; Random B=new Ra
我使用 touchstart 和 touchmove 事件编写了一些 Javascript 代码。我想用 Selenium 来测试它。我刚刚发现了TouchActions具有 move 方法的类似乎正
我正在尝试在 native iOS 应用程序中自动执行长按触摸操作。 方法一:模拟左上角长按,无效。 新的 TouchAction(driver).longPress(0,0).perform()Ap
我在向下滚动到 iOS 和 Android 应用程序中的某个元素时遇到问题。自从 Appium 1.6.3 更新到 1.7.1 以及 io.appium 更新到 6.1.0 以来,不推荐使用滑动方法,
我正在使用 appium 1.13.0 尝试使用此方法在 Android 8.1 上的三星 Galaxy Note 9 上滚动浏览 native Android 应用程序 new TouchActio
我正在通过 Nightwatch 和 Appium 运行一些测试,但我无法使用 iOS 模拟器成功实现滚动操作。我的测试设置为能够在 Chrome、Safari 或 Firefox 浏览器或使用 Sa
我的 Appium Java 代码: package Generic; import java.net.MalformedURLException; import java.net.URL; impo
返回错误:java.lang.SecurityException:在 appium 中使用 touchaction 类时注入(inject)到另一个应用程序需要 INJECT_EVENTS 权限 tr
我是一名优秀的程序员,十分优秀!