What is CSS?
Simple Web Page without CSS:
Simple Web Page with CSS:
What is CSS Selector:
CSS selectors are used to select the content you want to style. CSS selectors select HTML elements according to its id, class, type, attribute etc.
XPath Vs cssSelector
1. Locate by id (using symbol # hash)
Syntax: tag#id or #id
Example: input#user_login or #user_login
2. Locate by className (using symbol . dot)
Syntax: tag.className
Example: input.input
3. Locate by Name or Attribute or using multiple attributes:
Syntax:
input[name=‘username']
input[name='log'],[id='input'],[type='text']
4. Match with Prefix or start with (using symbol ^ Exponential operator)
Syntax: tagname[Attribute^= ‘Prefix of Attribute value']
Example: input[name^='txtUser']
5. Match with suffix or ends with (using symbol $ dollar sign)
Syntax: tagname[Attribute$= ‘suffix of Attribute value']
Example: input[name$='name']
6. Match with substring or contains (using symbol * asterisk)
Syntax: tagname[Attribute*='subString of Attribue value']
Example: input[name*='User']
Please watch below video for more details:
- CSS stands for Cascading Style Sheets.
- CSS describes how HTML elements are to be displayed on screen.
- Why CSS is for locating web elements? --> To identify Dynamic web elements on webpage (Those elements whose attribute values are changing frequently by performing operation like page refresh so it is difficult to handle such elements so we use CSS and XPath to locate such elements).
Simple Web Page without CSS:
Simple Web Page without CSS |
Simple Web Page with CSS |
What is CSS Selector:
CSS selectors are used to select the content you want to style. CSS selectors select HTML elements according to its id, class, type, attribute etc.
XPath Vs cssSelector
- Xpath engines are different in each browser, hence make them inconsistent. Particularly in IE. IE does not have a native xpath engine.
- CSS is faster. It also improves the performance. It is very compatible across browsers.
- Writing CSS is not simpler than XPath.
Different Ways to locate element using cssSelector |
1. Locate by id (using symbol # hash)
Syntax: tag#id or #id
Example: input#user_login or #user_login
2. Locate by className (using symbol . dot)
Syntax: tag.className
Example: input.input
3. Locate by Name or Attribute or using multiple attributes:
Syntax:
- tagName[attributeName='value']
- [attributeName='value']
- tagName[attribute1='value'][attribute2='value']
- tagName[attribute1='value'],[attribute2='value']
input[name=‘username']
input[name='log'],[id='input'],[type='text']
4. Match with Prefix or start with (using symbol ^ Exponential operator)
Syntax: tagname[Attribute^= ‘Prefix of Attribute value']
Example: input[name^='txtUser']
5. Match with suffix or ends with (using symbol $ dollar sign)
Syntax: tagname[Attribute$= ‘suffix of Attribute value']
Example: input[name$='name']
6. Match with substring or contains (using symbol * asterisk)
Syntax: tagname[Attribute*='subString of Attribue value']
Example: input[name*='User']
Please watch below video for more details:
This article is a creative one and the concept is good to enhance our knowledge. Waiting for more updates.
ReplyDeleteselenium training in velachery
selenium training in tambaram
Java training in tambaram
SEO Training in Anna Nagar
Software Testing Training in T Nagar
Python training in chennai
Android Training in OMR
Software testing training in Anna Nagar
RPA Training in T nagar
Web Designing Course in T Nagar
You are providing a post that is very useful for developing my knowledge and I learn more info from your blog.
ReplyDeleteSoftware testing training in Anna Nagar
Software testing training in Tambaram
Dot Net Training in Velachery
Web Designing Course in T Nagar
Spoken English Classes in Velachery
German Classes in T Nagar
SEO Training in OMR
AWS Training in Velachery
Python course in Tambaram
Salesforce Training in Chennai
This comment has been removed by the author.
ReplyDelete