We are going to discuss about WebElements, Tags, Attributes in this session.
Let’s talk about the WebElement first.
If suppose, we have to login to our email or any eCommerce Website, then we need to enter username and password in the respective fields and then, we need to click on the login button. So, this username and password field and login button are nothing but WebElements.
There are many types of WebElements for a Website, but we will talk about only the important ones.
So, every WebElement will have 2 types of Attributes.
Mandatory Attributes are also called Tags. So, Let’s talk about Tags first.
Now, Let’s talk about Tags. As we have already seen that there are many types of WebElements like If you are in the market for superclone Replica Rolex , Super Clone Rolex is the place to go! The largest collection of fake Rolex watches online!
Type of WebElements.
Now, If we want to know, which element is a dropdown, which element is Button, which element is Link, which element is input Field. Then we need to take help of tags.
So, the tags is a type of attributes, which helps us in identifying the type of element. Tags give identity to an element. This is a reason, tags are called Mandatory Attributes of an Element.
Now, Let’s see that what is a tag for an Element
You would have noticed, that there are some WebElements with same tag name like Input field, checkbox, and radio button have same tag name i.e input, So how can we differentiate between them. We will see that, when we will discuss attributes of the WebElement.
How can we get the tag for an Element in a Website, So, Let’s see this in a Website. Inspect any element in the website, and that’s it, We can get the tag of that Web Element.
So, In our examples, We had seen that
paragraphs were written like this <p> </p>
buttons were written like this <button> </button>
Link was written like this <a> </a>
Input field was written like this <input> </input>
Dropdown was written like this <select> </select>
Image was written like this <img> </img>
Heading was written like this <h1> </h1>, <h2> </h2>
So, these greater than and less than signs called html tags. so, tags are always written inside html tags.
There are 2 types of html tags
So, tags will always be written inside opening tag and closing tag
Opening tag is written like – <p>, <button>, <a>, <input>, <select>
Closing tag is written like – </p>, </button>, </a>, </input>, </select>
So, this is it about Tags.
Now, Lets talk about Attributes.
Attributes are called, Optional Attributes as well. Attributes provides extra information about the WebElement. Attributes are always written inside the opening tags. A WebElement can have multiple Attributes.
Attributes are made up of 2 parts
Now, Let’s see this in the website.
As we know that the attributes are always written inside the opening html tag of the tag. So, the syntax for the attributes could be like this.
How to find out the attribute for an Element – If you want to find out the attribute for an Element, then you need to inspect Element, and then you will be able to find out the attribute for that Element.
Now, the question comes, why should we read about tags and attributes of an element, and the answer is, “in order to locate an element in our test automation, we need to know about tags and attributes of an element.”
Sometimes, the common locators like, id, className, name, doesn’t work and it becomes difficult to locate an element using these locators, So, We should use xpath and cssSelector to locate the element, and if we know about tags and attribute of an element, then we can easily write xpath and cssSelector.
We have covered below topics in this session
Objects, Classes and Constructor in Javascript Classes and Objects A class in any programming language…
We will start from object oriented programming basics like What are different concepts in Object…
Why we can not over ride a Constructor This is a very important question, that,…
What is Arrow Function In the last session, We had discussed about Anonymous Function. Anonymous…
What is Anonymous Function Anonymous Function is a type of function which has no name…
What is Map, Reduce and Filter Map Filter and Reduce are higher order methods for…