How to launch chromebrowser using chrome options?

给你一囗甜甜゛ 提交于 2019-12-11 17:07:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!