The automation process in selenium can be followed as:
- Launching Browser
- Opening the desired website to be automated
- Locating web elements like textbox
- Performing operations on the located web elements like writing in the textbox
- Performing assertions like checking the “Success” message
Using Developer Tool
Locating web elements we need knowledge of their HTML attributes. For the source code of specific elements, we can use an in-built developer tool.
Here are the steps for finding HTML attributes:
- Lunch a website to be automated e.g. – “https://www.google.co.in/”
- Press F12 to lunch the developer tool
- Click on the inspect-element icon or we can use the command Ctrl +Shift + C.
- After clicking on the inspect element icon, click on the web element to be located.
- We can see the different attributes of the web elements like – Id, Class, and Name, along with its Tag like input, div, etc. Now we can use these tags, attributes, and values to locate elements using different locators.
Locators Use in Selenium WebDrive
There are 8 locators used in the selenium WebDrive
- By ID: Locators element using Id attributes in the web element.
- By className: Locators element using className in the web element.
- By tagName: Locators element using tagName in the web element
- By Name: Locators element using name attributes
- By linkText: Locators web element of link type using their Text
- By partialLinkText: Locators web element of link type with partial matching text.
- By cssSelector: Locators web element using CSS its CSS Selector patterns.
- By xpath: Locators web element using its XPATH.