Selenium WebDriver- Commands
Selenium commands, as we have discussed earlier in the IDE section are the set of commands used in Selenium that run your tests.
Given below are some of the most commonly used Selenium commands in WebDriver:
1. Fetching a web page
There are two methods to fetch a web page:
2. Locating forms and sending user inputs
3. Clearing User inputs
The clear() method is used to clear the user inputs from the text box.
4. Fetching data over any web element
Sometimes we need to fetch the text written over a web element for performing some assertions and debugging. We use getText() method to fetch data written over any web element.
5. Performing Click event
The click() method is used to perform click operation on any web element.
6. Navigating backward in browser history
7. Navigating forward in browser history
8. Refresh/ Reload a web page
9. Closing Browser
10. Closing Browser and other all other windows associated with the driver
11. Moving between Windows
13. Moving between Frames
14. Drag and Drop
Drag and Drop operation is performed using the Action class.
Let us consider a sample test script which will cover most of the commonly used WebDriver commands.
For our test purpose, we are using a dummy web page under the URL:
The default interface of the web page looks like this:
You can also use this dummy web page for your Selenium Testing practice.
First you need to download the browser driver for the browser on which you are willing to automate your test scenarios. We have already discussed execution of Selenium test scripts on different browsers in the previous sections of this tutorial.
For this test, we are using Firefox Gecko driver to automate our test scenarios on Firefox browser.
Below is the sample test script with embedded comments.