简体   繁体   English

java.lang.ClassCastException: org.openqa.selenium.firefox.FirefoxDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen

[英]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.

相关问题 java.lang.ClassCastException:org.openqa.selenium.By $ ById无法转换为org.openqa.selenium.WebElement - java.lang.ClassCastException: org.openqa.selenium.By$ById cannot be cast to org.openqa.selenium.WebElement 导入org.openqa.selenium.firefox.FirefoxDriver无法解析 - The import org.openqa.selenium.firefox.FirefoxDriver cannot be resolved java.lang.ClassCastException: 类 org.openqa.selenium.By$ByXPath 不能转换为类 org.openqa.selenium.WebElement - java.lang.ClassCastException: class org.openqa.selenium.By$ByXPath cannot be cast to class org.openqa.selenium.WebElement 不能访问org.openqa.selenium.firefox.FirefoxDriver类型 - The type org.openqa.selenium.firefox.FirefoxDriver is not accessible 线程“ main”中的异常java.lang.ClassCastException:java.util.HashMap无法转换为org.openqa.selenium.WebElement - Exception in thread “main” java.lang.ClassCastException: java.util.HashMap cannot be cast to org.openqa.selenium.WebElement 线程“主”中的异常java.lang.ClassCastException:无法将java.util.ArrayList强制转换为org.openqa.selenium.WebElement - Exception in thread “main” java.lang.ClassCastException: java.util.ArrayList cannot be cast to org.openqa.selenium.WebElement 收到错误-java.lang.ClassCastException:org.openqa.selenium.chrome.ChromeDriver无法转换为com.initialization.DriverInitialization - Getting the Error - java.lang.ClassCastException: org.openqa.selenium.chrome.ChromeDriver cannot be cast to com.initialization.DriverInitialization java.lang.ClassCastException:无法转换为 org.openqa.selenium.WebElement 使用 executeScript() 从 shadowHost 返回 shadowRoot - java.lang.ClassCastException: cannot be cast to org.openqa.selenium.WebElement using executeScript() to return shadowRoot from shadowHost java.lang.ClassCastException: com.sun.proxy.$Proxy8 不能转换为 org.openqa.selenium.internal.WrapsDriver - java.lang.ClassCastException: com.sun.proxy.$Proxy8 cannot be cast to org.openqa.selenium.internal.WrapsDriver java.lang.ClassCastException:通过Selenium执行测试时,无法将java.base / java.lang.String强制转换为org.openqa.selenium.WebElement - java.lang.ClassCastException: java.base/java.lang.String cannot be cast to org.openqa.selenium.WebElement when executing test through Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM