There may be cases where simple changes are made to the application and our previously identified CSS statements wont work after those simple changes are made to the application. In order to avoid these kind of problems, we've to optimize our CSS selector Statements before using them in our Selenium Automation.
So that Advantages of Optimizing the CSS Statements are to get the shortest and least breakable CSS selector Statements.
We've to follow the below three strategies in order to make the CSS statements Optimized:
- Use the id attribute if available but not used
- Use the combination of attributes to make the CSS more specific
- Use the Relative CSS instead of Absolute CSS Statements
Lets implement all the above three strategies that are required to make our CSS selector statements Optimized in the upcoming posts.
To start with, lets implement the first strategy to optimize the CSS Statements in next post.
Please comment below to feedback or ask questions.
CSS selector Optimization Strategy One - Use the id attribute if available for the element but not used will be explained in the next post.