Thursday, December 10, 2020

Debug your WebDriver script easily by connecting to existing Chrome Browser


Step1:

Open Chrome browser using --remote-debugging-port

Step2:
Ensure you have correct chromedriver.exe downloaded which matches with your chrome browser version.

Step3:
Connect to this browser by writing a separate code for debug to handle browser

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("debuggerAddress","localhost:1234");

ChromeDriver driver = new ChromeDriver(chromeOptions);
..... 
......

Notes: You can set your application from where you want to test , and start from respective step.

In this example used port 1234 , you are free to use any available port in your system.