If we want to run selenium execution in an open browser, (in mac machine) we need to first find out our chrome location in mac. Mostly, it remains under the Application folder if you have not done any specific changes while installing the browser.
Once you get the location, create a new folder at any location and copy its path.
I created an in-home location.
Once this is done, run this command in the terminal:
% /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 -user-data-dir=chromedata
It will open a new chrome browser, where we can debug our fix. Now in your automation script, put a option for chromedriver debugging.
options.setExperimentalOption("debuggerAddress", "localhost:9222");
Now Provide this option to your chromedriver.
In My case, it was something like this:
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
driver = new ChromeDriver(capabilities);
Now when you will run your script it will run in this already open browser.
Note: Port number, directory location is optional.
For windows, check this link: Selenium Script execution on already open browser Windows OS
No comments:
Post a Comment