How to execute selenium script on open browser
Lets say we are working on a test script for a certain page (Ex: Email
or Phone in Facebook application) in the application for that we can manually
launch the browser and navigate to that page and then run the automation
script. This is very useful for debugging the objects.
Below are the few
steps to following for execute your scripts on open chrome browser.
Find Where your chrome.exe file in your local desktop/laptop
Ex: C:\Program Files
(x86)\Google\Chrome\Application
Set the path in environment variable
Open command prompt and enter the below command
-remote-debugging-port
=9009 is the port .port number can be any number
–user-data-dir : create your own profile directory and assign the
path to
Ex: C:\ChromeProfile\Debug
Chrome browser will get launch once you run the above command from command prompt. Manually open the browser and enter the URL and navigate where you desired page.
Below is the script for enter phone no or
email address on Find your account text box
public static void main(String[] args)
throws InterruptedException {
String driverPath="C:\\Ddrive\\TProgrames\\seleniumSoftware\\chromedriver_win32\\";
System.out.println("launching chrome browser");
System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe");
ChromeOptions options=new ChromeOptions();
options.setExperimentalOption("debuggerAddress","LocalHost:9009");
driver = new ChromeDriver(options);
// give locator information here
driver.findElement(By.xpath("//input[@id='identify_email']")).clear();
driver.findElement(By.xpath("//input[@id='identify_email']")).sendKeys("abc@xyz.com");
}
Note:
your chrome browser should be 66 and above
Comments
Post a Comment