Browser Commands

Browser commands include all the operations which are probably performed on the browser, like an example opening of a browser, getting the title of the browser, etc.


Given below are some of the commonly used Browser commands for Selenium WebDriver.

1. Get Command

This method is used to load a web page to the browser window. By this method, WebDriver will wait until the page has fully loaded (that is, the onload event has fired) before returning control to your test or script. This method accepts string as a parameter and returns void.

driver.get(“https://demoapp1.tequality.tech/”);
 

2. Get Current URL Command

This method is used to get the URL of the web page which user is currently accessing. It doesn’t accept anything as a parameter and returns string value.

String CurrentUrl= driver.getCurrentUrl();
 

3. Get Title Command

This method is used to get the title of the webpage which user is currently accessing. It doesn’t accept anything as a parameter and returns string value.

driver.getTitle();
 

4. Close Command

This method is used to close the current open window which driver has focus on. All other browser windows remain open, and the webdriver instance also remains open and usable. While dealing with multiple tabs or windows this method is used. It doesn’t accept anything as a parameter and returns void.

driver.close();
 

5. Quit Command

This method closes all the browser instances. It closes all browser windows associated with that driver and safely ends the driver session gracefully. It doesn’t accept anything as a parameter and returns void.

driver.quit();