问题
Without using The System.setProperty
System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");
I have tried to launch the chrome browser using chrome options with the below code:
ChromeOptions options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
i have set my chromedriver path in my System variables.It not Working can any figure this out.
回答1:
Can you please try below code as set Binary also into Options to launch chromeBrowser:
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Users\\raheela.aslam\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"); //Path where the Chrome.exe exist in your machine.
System.setProperty("webdriver.chrome.driver", "C:\\chrome_driver\\chromedriver.exe");
driver = new ChromeDriver(options);
回答2:
There is another way to launch chrome without setting property. This downloads the latest chrome driver version and starts it. You can use WebDriverManager within using bonigarcia dependency.
bonigarcia dependency
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
来源:https://stackoverflow.com/questions/53257059/how-to-launch-chromebrowser-using-chrome-options