Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open usual chrome or Firefox window while using Selenium Webdriver?

When you start a Web-driver using Selenium, It opens a new and very fresh instance of respective web browser ( looks as if just installed, no history and default settings}.

Is there any way to open usual windows which will have customized settings which I have done in my chrome or Firefox like add-ons and all ?

like image 643
mkkhedawat Avatar asked Sep 29 '22 20:09

mkkhedawat


1 Answers

You can use existing profile in FireFox

File profileDir = new File("Path to default profile")
FirefoxProfile firefoxProfile = new FirefoxProfile(profileDir);    
WebDriver webDriver = new FirefoxDriver(firefoxProfile);

For Chrome, you can go with options as below:

ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");
driver = new ChromeDriver(options);
like image 176
nitin chawda Avatar answered Oct 05 '22 07:10

nitin chawda