UDEMY - SK - XPath Tutorial From Basic To Advance Level
UDEMY - SK - XPath Tutorial From Basic To Advance Level
v. Telegram: https://t.me/rajatt95
i. Appium + Java
c. API
-------------------------------------------------------------------------------------------------------------------------------
1
—------------------
3. Documents:
b. Google Drive:
https://drive.google.com/drive/folders/1tne9pZjgWvfrS0l9tVHs6k1jnQHpTLoA
============================================================================
-----------------------------------------
========1_Introduction & basic concepts of XPath==========
-----------------------------------------
1. XPath:
a. Each and every element on the web page has its own address
b. XPath is the address of an element
2. Importance of XPath:
a. As Important as the Tyres of a car
b. Scripts should not break
—------------------
3. How to write XPath:
a. Absolute: Single forward-slash (/)
i. Coming to Element step-by-step
ii. This makes XPath performance very slow
iii. Starts from HTML tag
b. Relative: Double forward-slash (//)
i. Directly jump to the element
c. XPath syntax functions
i. /tagName
ii. //tagName[@attribute=’attributeValue’]
iii. AND, OR functions
iv. text(), normalize-space(), .
v. Index, position.last,etc.
vi. Relative XPath using axes
vii. Relative XPath without using axes
-------------------------------------------------------------------------------------------------------------------------------
2
—------------------
1.
iii. Search: Not only for XPath
1. Find By String, Selector, or XPath
b. SelectorsHub
i.
ii. SVG elements, Frames, Shadow DOM
iii. Intelli sense
—------------------
-------------------------------------------------------------------------------------------------------------------------------
3
-----------------------------------------
===2_Writing normal XPath and relative XPath with advanced concepts=====
-----------------------------------------
1. Relative XPath:
a. //tagName[@attribute=’attributeValue’]
b. //tagName[contains(@attribute,’subStringOfattributeValue’)]
c. //tagName[text()=’value’]
d. //tagName[contains(text(),’value’)]
e. //tagName[normalize-space()=’value’]
i. normalize-space() -> removes the unnecessary spaces
f. //a[@title='Platform' and @class='dropdown-toggle']
g. //a[@title='Platform' or @class='dropdown-toggle']
—------------------
NOTE:
1. text() -> not supported by cssSelector
—------------------
—------------------
-------------------------------------------------------------------------------------------------------------------------------
4
-----------------------------------------
========3_XPath for special types of Elements==========
-----------------------------------------
1. SVG elements:
a. These are the vector elements
b. Used to provide the icons over the web page
c. https://testproject.io/
d.
e. //a[@href='https://twitter.com/TestProject_io']//*[local-name()='svg']
f. SVG element : //*[local-name()=’svg’]
g. Path element : //*[name()=’path’]
—------------------
d.
e. Shadow DOM
i. Open -> we can access DOM inside it
ii. Close -> we can not access -> SECURITY
—------------------
-------------------------------------------------------------------------------------------------------------------------------
5
—------------------
3. iFrames:
a.
—------------------
4. Dynamic elements (which disappear from DOM):
a. Right-click -> Selectors Hub -> Copy Relative XPath
i.
—------------------
-------------------------------------------------------------------------------------------------------------------------------
6
—------------------
b. Turn on Debugger
i.
-----------------------------------------
========4_Tips and tricks==========
-----------------------------------------
1.
—------------------
-------------------------------------------------------------------------------------------------------------------------------
7
-----------------------------------------
========5_Locator Challenge==========
-----------------------------------------
a.
------------------------------------------
1.
2. //ul[@class=’footer__socials’]//a/@href -> Gives all the links
—----------------
-------------------------------------------------------------------------------------------------------------------------------
8
=======================================================================
1. Documents
b. Google Drive:
https://drive.google.com/drive/folders/1tne9pZjgWvfrS0l9tVHs6k1jnQHpTLoA
3. To connect
a.
=======================================================================
=======================================================================
-------------------------------------------------------------------------------------------------------------------------------