![](/img/trans.png)
[英]Not able to launch IE browser using Selenium2 (Webdriver) with Java
[英]Could not able to launch chrome browser using the selenium webdriver
import org.openqa.selenium.chrome.ChromeDriver;
public class launch {
public static void main(String[] args) {
// TODO Auto-generated method stub
ChromeDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
}
}
錯誤:
Could not find or load main class org.openqa.grid.selenium.GridLauncherV3
在 Launch class 中,您將直接創建 ChromeDriver class 的 object 而不提供 chrome 驅動程序路徑。 因此,在創建 ChromeDriver object 之前,您需要添加:
System.setProperty("webdriver.chrome.driver","path of chromedriver.exe file");
如果您已下載 chrome 驅動程序 exe 文件,則需要傳遞該路徑。 在此之后創建 ChromeDriver class 的 object。
您需要設置系統屬性webdriver.chrome.driver
如下:
System.setProperty("webdriver.chrome.driver", '/path/to/chromedriver');
此外,不要使用ChromeDriver ,而是使用WebDriver接口,如下所示:
WebDriver driver = new ChromeDriver();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.