下面的代碼使使用Selenium的瀏覽器自動化。錯誤:他必須通過webdriver.ie.driver系統屬性設置驅動程序可執行文件的路徑
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\trainee\\Downloads\\chromedriver_win32\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https:\\www.google.com");
//driver.manage().window().maximize();
String str=driver.getCurrentUrl();
System.out.println(str);
String abc=driver.getTitle();
System.out.println(abc);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.MINUTES);
driver.findElement(By.id("lst-ib")).click();
driver.findElement(By.id("lst-ib")).sendKeys("Gmail");
driver.findElement(By.id("lst-ib")).submit();
}
當我執行的代碼,我得到這個錯誤:
java.illegalstateexception: The path to the driver executable must be set by the webdriver.ie.driver system property".
我給了正確的路徑,其中在系統中安裝的鍍鉻驅動的代碼,儘管我面對這問題。請幫我解決一下這個。
你還可以添加錯誤跟蹤? –
你使用鉻瀏覽器或即瀏覽器,因爲你問它是ie瀏覽器,但在代碼中它是鉻? – Murthi