XPath functions.

1. Single attribute

//input[@vale=‘user’]

Double attribute

//span[@title=’user’][@class=’xyz’]

2. Parent

//div[@class=’home-page’]//parent::div

3. Ancestor

//div[@class=’home-page‘]//ancestor::div

4. Child

//div[@class=’home-page‘]//child::input[1]

5. Descendant

//div[@class=’home-page‘]//descendant::a

6. Following

//li[@class=’home-page‘]//following::input

//li[@class=’home-page‘]//following-sibling::div

7. Preceding

//div[@class=’form-group’]//preceding::input

//div[@class=’form-group’]//preceding-sibling::div

8. index based

(//input[@class=”home-page“])[3]

//input[@class=”home-page“][2]

//input[@class=”home-page“][last()]

//input[@class=”home-page“][last()-1]

9. Text value

//span[text()=’CONTINUE’]

//span[contains(text(),’CONTINUE’)]

//span[starts-with(text(),’CONTINUE’)]

//span[contains (.,’CONTINUE’)]

//span[.=’CONTINUE’]

10. And/Or

//input[@type=’submit’ or @name=’btnReset’]

//input[@type=’submit’ and @name=’btnLogin’

 

XPath and cssSelector Error Handling

 

1. //svg is the wrong format. SVG elements doesn’t support the standard xpath format. It has a different format.

wrong format – //svg

correct format for svg-

//*[local-name()=’svg’]

and for svg child- Suppose path tag is the child element of svg then the format will be

wrong format- //path

correct format – //*[name()=’path’]

2. Shadow DOM elements don’t support xpath so we can write only cssSelector for shadow DOM elements.
 
3. After / only tagname * and . is allowed
wrong xpath – //li-icon[@type=’camera-icon’]/../*/

correct format- //li-icon[@type=’camera-icon’]/../*/div

 
4. Just after ] text is not allowed.
wrong format – //li-icon[@type=’camera-icon’]div
correct format – //li-icon[@type=’camera-icon’]//div
 
 

 

cssSelector function

 

#id

.class

tagName[attributeName=’attributeValue’]

tagName[attributeName$=’ending value of attributeValue’]

tagName[attributeName^=’starting value of attributeValue’]

tagName[attributeName*=’substring of attributeValue’]

$ – ends with 

^ – starts with 

* – contains

 

Descendant combinator
The   (space) combinator selects nodes that are descendants of the first element.
Syntax: A B
Example: div span will match all <span> elements that are inside a <div> element.
Child combinator
The > combinator selects nodes that are direct children of the first element.
Syntax: A > B
Example: ul > li will match all <li> elements that are nested directly inside a <ul> element.
General sibling combinator
The ~ combinator selects siblings. This means that the second element follows the first (though not necessarily immediately), and both share the same parent.
Syntax: A ~ B
Example: p ~ span will match all <span> elements that follow a <p>, immediately or not.
Adjacent sibling combinator
The + combinator selects adjacent siblings. This means that the second element directly follows the first, and both share the same parent.
Syntax: A + B
Example: h2 + p will match all <p> elements that directly follow an <h2>.
Column combinator 
The || combinator selects nodes which belong to a column.
Syntax: A || B
Example: col || td will match all <td> elements that belong to the scope of the <col>.

The :first-child CSS pseudo-class represents the first element among a group of sibling elements.

/* Selects any <p> that is the first element
   among its siblings */
p:first-child {
  color: lime;
}

The :last-child CSS pseudo-class represents the last element among a group of sibling elements.

/* Selects any <p> that is the last element
   among its siblings */
p:last-child {
  color: lime;
}

The :nth-child() CSS pseudo-class matches elements based on their position in a group of siblings.

/* Selects the second <li> element in a list */
li:nth-child(2) { 
  color: lime;
}

/* Selects every fourth element
   among any group of siblings */
:nth-child(4n) {
  color: lime;
}

The :nth-last-child() CSS pseudo-class matches elements based on their position among a group of siblings, counting from the end.

/* Selects every fourth element
   among any group of siblings,
   counting backwards from the last one */
:nth-last-child(4n) {
  color: lime;
}

The :first-of-type CSS pseudo-class represents the first element of its type among a group of sibling elements.

/* Selects any <p> that is the first element
   of its type among its siblings */
p:first-of-type {
  color: red;
}

The :last-of-type CSS pseudo-class represents the last element of its type among a group of sibling elements.

/* Selects any <p> that is the last element
   of its type among its siblings */
p:last-of-type {
  color: lime;
}

ron geremy male enhancement pills buy generic erection pills shark 5k male enhancement pills reviews top selling penis enlargement pills what male enhancement pills work the best how to make your penis bigger manually black 4k male enhancement pills in case best generic ed pills edge penis pills male enhancement pills reddit 2022 how do penis pills work how to get a bigger penis natural way penis growing pills for teens are safe pills that give an erection do pills estrogen make your penis soft how to last longer in bed exercises for men truth about penis enlargements pills and cream how to make your penis bigger in weeks

does one bruise easy on blood pressure medicine pregnant high blood pressure medication what is the medicine of low blood pressure why does my blood pressure medicine make me tired fda recalls blood pressure and heart medicine high blood pressure medication yellow teeth blood pressure medicine natural most recent blood pressure medications blood pressure medications causing gout blood pressure medication and garlic medication to avoid with high blood pressure blood pressure medications common blood pressure medication and hot weather linden infusion and high blood pressure meds blood pressure meds assistance best sinus medicine with high blood pressure blood pressure meds safe with psoriasis lactose free blood pressure medication

how long do cbd gummies show up on drug test are cbd gummies illegal in pa beezbee cbd thc gummies royal cbd gummies legal in texas cbd infused chill gummies diamondcbd chill plus gummies cbd amount phat hempies cbd gummies do they have thc in it sera labs cbd gummies re leaved cbd gummies cbd benefits gummies how to take 10mg cbd gummies should i eat cbd gummies boxes eco cbd gummies plus cbd thc gummies top royal cbd gummies cbd gummy bears lair relieve pain re assure cbd gummies 20 mg cbd gummies effects

prevention medicine diabetes complications medicine cause diabetes diabetes medications that cause glucose in urine dr oz diabetes medicine type 2 diabetes medications rybelsus z diabetes medication hrsi diabetes medication amaryl medication for diabetes type one diabetes insulin meds blood pressure meds cause diabetes mechanism of diabetes meds medicine for dry cough for diabetes patients diabetes tip 2 drugs free prescription average a1c reduction with diabetes medications what diabetes drugs does glaxosmithkline make jandice medication for diabetes lower blood sugar for type 1 diabetes patients diabetes meds for elderly

keto weight loss pills side effects at home exercises to lose lower belly fat pills with a side effect of weight loss how to lose belly fat in 2 days fitbit weight loss can i take weight loss pills teen diet pills dr oz reviews best legal weight loss pills a fast way to lose weight recall on alli diet pills i need something to help me lose weight fast it works keto coffee reviews weight loss paula deen weight loss and medication diabetes medication causing unwanted weight loss menu to lose belly fat what medication for anxiety causes weight loss does waist trainers help you lose belly fat keto cheat pills