[英]java.lang.ClassCastException: org.openqa.selenium.firefox.FirefoxDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
I am trying to automate a touch event using Selenium.我正在尝试使用 Selenium 自动化触摸事件。 First time doing it.
第一次做。 This is my code:
这是我的代码:
public void getarrowright() throws Exception {
new AccessibilityPage(driver).getdragmeframe();
BrowserUtils.waitForVisibility(rightarrow,30,driver);
Actions action = new Actions(driver);
action.moveToElement(rightarrow).click().perform();
TouchActions tapAction = new TouchActions(driver).singleTap(rightarrow);
tapAction.perform();
}
I am getting that as an error.我认为这是一个错误。 This is how my driver page looks like:
这是我的驱动程序页面的样子:
case "firefox":
caps = DesiredCapabilities.firefox();
FirefoxOptions ffOpts = new FirefoxOptions();
FirefoxProfile ffProfile = new FirefoxProfile();
ffProfile.setPreference("browser.autofocus", true);
ffProfile.setPreference("browser.tabs.remote.autostart.2", false);
caps.setCapability(FirefoxDriver.PROFILE, ffProfile);
caps.setCapability("marionette", true);
// then pass them to the local WebDriver
if (platform.equalsIgnoreCase("local")) {
System.setProperty("webdriver.gecko.driver", "src/main/resources/Drivers/geckodriver.exe");
webDriver.set(new FirefoxDriver(ffOpts.addCapabilities(caps)));
}
break;
Can someone please help?有人可以帮忙吗? Thanks
谢谢
Access to touch screen capabilities is an optional feature.访问触摸屏功能是一项可选功能。 Driver implementations that support this feature implement the HasTouchScreen interface.
支持此功能的驱动程序实现实现 HasTouchScreen 接口。 According to Javadoc, ChromeDriver is so far the only implementation that implements this interface:
根据 Javadoc,ChromeDriver 是迄今为止唯一实现此接口的实现:
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/interactions/HasTouchScreen.html https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/interactions/HasTouchScreen.ZFC35FDC70D5FC69D269883A822CZA7
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.