Thursday, 26 March 2015

Selenium WebDriver Browser Commands

Selenium WebDriver Browser Commands

The very first thing you like to do with Selenium is to opening and closing a new browser. Below are the numbers of commands you can apply on the Selenium opened browser.

Get Command

Purpose: This command is use to open a new web page in the current browser.
Command: driver.get(URL);
Parameters: url – The URL to load. It is best to use a fully qualified URL

Get Title Command

Purpose: This command is use to get the title of the current page.

Get Current URL Command

Purpose: This command is use to get the URL of the page currently loaded in the browser.

Get Page Source Command

Purpose: This command is use to get the source of the last loaded page.

Close Command

Purpose: This command is use to close the current window of the browser, if it’s the last window it will close the browser.

Quit Command

Purpose: This command is use to quit the browser and all the opened windows in the browser.

Refresh Command

Purpose: This command is use to refresh the current browser.

Please see 5 ways of refresh browser:

Practice Exercise

1) Launch a new Firefox browser.
2) Open ToolsQA.com
3) Get Page Title name and Title length
4) Print Page Title and Title length on the Eclipse Console.
5) Get Page URL and URL length
6) Print URL and URL length on the Eclipse Console.
7) Refresh current page
8) Get Page Source (HTML Source code) and Page Source length
9) Print Page Source and length on Eclipse Console.
10) Close the Browser.

Solution


No comments:

Post a Comment