What are the commonly used attributes in automation testing?
There are a number of attributes in HTML. However, only a few of them are used majorly for automation testing. Here are some of them:
- id: Used to identify unique WebElements in the DOM
- class: Helps in classifying similar WebElements
- style: Adds CSS styling to the WebElements
- title: Provides contextual information of the elements
Some of the major categories of attributes include:
Required Attributes: These attributes are a must for HTML tags. For example, you cannot display an image on the page without src for .
Optional Attributes: These attributes helps in giving more meaning to the elements. For example – the title for provides a title to the image, however, not mandatory.
Event Attributes: These attributes are triggered based on the user’s actions. For example – When you hover a mouse pointer on a particular element, it triggers the onmouseover event.
Standard Attributes: These are global attributes that can be used in almost all the HTML tags (e.g. id, class, style, etc.).