Learn Selenium With Quiz – Basic Level 8 – CSS Selector
As a part of a Series of posts on Learn Selenium With Quiz, This set contains questions from CSS Selector concepts in Selenium WebDriver. I will suggest you to go through below link before taking up quiz:
CSS Selector in Selenium WebDriver
Quiz will be auto submitted once you answer all question.
Direct child is immediate child of a node. For example:- A Son of a father will be direct child. We can represent a direct child of node using '>'. For e.g. "div > input" will locate all direct input child of div tag.
How to represent any child (Child and Subchild) of a parent node using CSS selector?
All child of a parent node will include all immediate child and child of child. We can represent all child of node using a whitespace . For e.g. "div input" will locate all input child of div tag.
What is the correct css selector to locate an element using its an attribute?
The CSS syntax of locating an element using its attribute is below:- tagName[attributeName='attributeValue']. Remember here that we do not use '@' symbol like XPath here.
What is the correct css selector to locate an element using its multiple attributes?
The CSS syntax of locating an element using its multiple attribute is below:- tagName[attributeName='attributeValue'][attributeName='attributeValue']....... Add more attribute with its value in similar fashion. Remember here that we do not use '@' symbol like XPath here.
Which element is represented by CSS "#someValue"?
In CSS, we can locate an element with its id using '#'. For example if an input tag has an id with value "firstName", CSS will be #firstName.
Which element is represented by CSS ".someValue"?
In CSS, we can locate an element with its class using '.'(dot) . For example if an input tag has a class with value "firstName", CSS will be .firstName.
What is difference between input#someValue and #someValue?
'#' is short notation to represent id. input#someValue :- All input tags with id as someValue #someValue :- All tags with id as someValue
What is difference between input.someValue and .someValue?
',' is short notation to represent class name. input.someValue :- All input tags with class as someValue .someValue :- All tags with class as someValue
What is represented by css "input[id^='someValue']"
'^' represent starts with.
What is represented by css "input[id$='someValue']"
'$' represents ends with.
If you find this helpful, please share with others.
#ThanksForSharing