线程“主” org.openqa.selenium.WebDriverException中的异常:未知错误:无法读取未定义的属性“ compatMode”

时间:2019-01-04 10:29:11

标签: java selenium

当我在Google Chrome浏览器中运行自动化脚本时,我面临以下问题。

代码:

    System.setProperty("webdriver.chrome.driver", 

   "D:\\Selenium\\drivers\\chromedriver.exe");  
    WebDriver driver = new ChromeDriver(cap);

    driver.get(url);
    Thread.sleep(2000);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    Thread.sleep(2000);
    driver.findElement(By.id("ImgLogo")).click();
    System.out.println("logo was clicked");

    driver.findElement(By.xpath("//input[@id='TxtUserId']")).sendKeys("AUT11");
    driver.findElement(By.xpath("//input[@id='TxtPwd']")).sendKeys("AUT11");

    driver.findElement(By.xpath("//input[@id='btnSecureLogin']")).click();

    driver.quit();
}

错误:

Starting ChromeDriver 2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387) on 
port 25570
Only local connections are allowed.
Jan 04, 2019 3:44:50 PM org.openqa.selenium.remote.ProtocolHandshake 
createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown 
error: Cannot read property 'compatMode' of undefined
 (Session info: chrome=71.0.3578.98)
(Driver info: chromedriver=2.45.615291 
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1 
x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds

请帮助我解决这个问题。

1 个答案:

答案 0 :(得分:0)

尝试此代码

System.setProperty("webdriver.chrome.driver","C:\\Users\\Desktop\\chromedriver_2.45.exe");  
WebDriver driver = new ChromeDriver();