繁体   English   中英

Click()操作不适用于Selenium Webdriver中的Firefox

[英]Click() action is not working with firefox in selenium webdriver

  1. 以下代码不适用于点击操作。
  2. 我已经在chrome上尝试过了,但是在Firefox上却无法使用。

      package SeleniumCase; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class SeleniumClass { public static void main(String[] args) { WebDriver driver; System.setProperty("webdriver.gecko.driver","E:\\\\Librar\\\\geckodriver.exe"); driver = new FirefoxDriver(); driver.get("my company url hide for security reason"); driver.findElement(By.id("UserName")).sendKeys("admin@school.com"); driver.findElement(By.id("next")).click(); driver.findElement(By.id("Password")).sendKeys("passw0rd"); driver.findElement(By.id("submit")).click(); } } 

您有任何错误吗?请分享例外或错误

尝试这个

JavascriptExecutor js = (JavascriptExecutor) driver;
            js.executeScript("var evt = document.createEvent('MouseEvents');" + "evt.initMouseEvent('click',true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0,null);" + "arguments[0].dispatchEvent(evt);",  webElement);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM