Home » selenium-tutorial » Webdriver-Browser Commands

Newly Updated Posts

Webdriver-Browser Commands

Webdriver browser commands are those commands in selenium webdriver from where we can perform any browser operation with defined set of method.

The Method which is called using (.) from reference variable of browser object (can be any chrome,firefox, ie etc) have method with parameter and it return with particular return type or void(no return type).

Lets discuss the Webdriver-Browser commands in details.

1) get command: This method loads a new URL or Webpage on the existing web browser and return void (no return type).The method is displayed void.

Command– driver.get();

Code: driver.get(“http://www.google.com”); String URL = “https://code2test.com”;

2) getTitle(): In Webdriver , the get title retrieves the title of the current web page as it don not accept any parameter and returns a string.

Code: driver. getTitle(“http://www.google.com”);

3) getCurrentUrl(): This method return String, it basically retrives the Url of the current web page treats it as a string .

Code:  String CurrentUrl = driver.getCurrentUrl();

4) getPageSource(): In Webdriver, getPageSource() method helps to extract the sourcecode of your current web page present in browser.

Code: driver. getSourceCode();

5) close():