520 likes | 653 Views
This presentation on XPath in Selenium will help you learn the basics of XPath in Selenium. In the process, you shall see the syntax of XPath and several types of XPath locators. After that, we shall understand what the two types of XPaths with their respective syntax are. Then we shall learn about the XPath Functions and the types of XPath Functions. Towards the end, we shall see the XPath Axes, their relevance, and different XPath Axes in Selenium.<br><br>The topics covered in the video are:<br>1. What is XPath in Selenium?<br>2. Types of XPath<br>3. XPath Functions<br>4. Types of XPath Functions<br>5. XPath Axes<br><br>Post Graduate Program in DevOps:<br>This program, designed in collaboration with Caltech CTME, prepares you for a career in DevOps, bridging the gap between software developers and operations teams. Our unique Blended Learning combines live online classes, interactive labs and more, giving you hands-on experience and job-ready skills. This Post Graduate Program in DevOps will help you master the art and science of improving the development and operational activities of your entire team. You will build expertise via hands-on projects in continuous deployment, using configuration management tools such as Puppet, SaltStack, and Ansible.<br><br>u2705 Caltech CTME Post Graduate Certification<br>u2705 Receive 25 CEUs from Caltech CTME upon course completion<br>u2705 Caltech CTME Circle Membership<br>u2705 Online Convocation by Caltech CTME Program Director<br>u2705 Master classes with Caltech CTME instructors<br>u2705 Physical Certificate from Caltech CTME (on request)<br>u2705 250 hours of Applied Learning<br>u2705 Enrollment in Simplilearnu2019s JobAssist<br>u2705 Get noticed by the top hiring companies<br>u2705 20 real-life projects on integrated labs<br>u2705 Capstone project in 3 domains<br><br>Learn more at: http://bit.ly/3nc827A
E N D
What is XPath? • XPath is a Selenium technique used to navigate through the HTML structure of the webpage • It uses the XML path expression to find elements on a webpage <xpath>
What is XPath? • XPath is a Selenium technique used to navigate through the HTML structure of the webpage • It uses the XML path expression to find elements on a webpage <xpath>
Syntax of XPath XPath = //tagname[@Attribute = ‘Value’]
Syntax of XPath Select Current node XPath = //tagname[@Attribute = ‘Value’]
Syntax of XPath Select Current node XPath = //tagname[@Attribute = ‘Value’] Tagname like input
Syntax of XPath Select Current node Selects Attribute XPath = //tagname[@Attribute = ‘Value’] Tagname like input
Syntax of XPath Select Current node Selects Attribute XPath = //tagname[@Attribute = ‘Value’] Tagname like input Attribute Name
Syntax of XPath Select Current node Selects Attribute Value of the attribute XPath = //tagname[@Attribute = ‘Value’] Tagname like input Attribute Name
Types of XPath Locators There are several types of XPath Locators
Types of XPath Locators There are several types of XPath Locators
Types of XPath Locators There are several types of XPath Locators
Types of XPath There are two types of XPaths
Types of XPath There are two types of XPaths
Types of XPath There are two types of XPaths Absolute XPath
Types of XPath There are two types of XPaths Absolute XPath Relative XPath
Types of XPath Absolute XPath • Absolute XPath is a direct way of finding an element • The drawback is that if there are any changes in the elements path then XPath will fail
Types of XPath Absolute XPath • Absolute XPath is a direct way of finding an element • The drawback is that if there are any changes in the elements path then XPath will fail
Types of XPath Absolute XPath Absolute XPath:/html/body/div[1]/div/div[2]/header/div/div[2]/a/img
Types of XPath There are two types of XPaths: Absolute XPath Relative XPath
Types of XPath Relative XPath • Relative XPath begins from the middle of the HTML DOM structure • It enables writing from the middle of the HTML DOM structure without any need to write a long XPath
Types of XPath Relative XPath • Relative XPath begins from the middle of the HTML DOM structure • It enables writing from the middle of the HTML DOM structure without any need to write a long XPath
Types of XPath Relative XPath Relative XPath://*[@id=”block-perfecto-main-menu”]/ul/li[6]/a
XPath Functions • XPath in Selenium provides XPath functions for writing efficient XPaths to discover elements uniquely • XPath Functions helps in locating web elements when there are elements that have similar properties and simple XPath strategies fail
XPath Functions • XPath in Selenium provides XPath functions for writing efficient XPaths to discover elements uniquely • XPath Functions help in locating web elements when there are elements that have similar properties and simple XPath strategies fail
Types of XPath Functions XPath Contains () • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc.
Types of XPath Functions XPath Contains () • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc.
Types of XPath Functions XPath Contains () • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc //tag_name[contains(@attribute,’value_of_attribute’)]
Types of XPath Functions XPath Contains () • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc
Types of XPath Functions XPath Contains () XPath Text () • The XPath Text() is a function used to locate the element on a web page using the web element's text • The function proves its worth if the element contains a text, like a label, etc. • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc
Types of XPath Functions XPath Contains () XPath Text () • The XPath Text() is a function used to locate the element on a web page using the web element's text • The function proves its worth if the element contains a text, like a label, etc. • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc
Types of XPath Functions XPath Contains () XPath Text () • The XPath Text() is a function used to locate the element on a web page using the web element's text • The function proves its worth if the element contains a text, like a label, etc. • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc //tag_name[contains(@attribute,’value_of_attribute’)]
Types of XPath Functions XPath Contains () XPath Text () • The XPath Text() is a function used to locate the element on a web page using the web element's text • The function proves its worth if the element contains a text, like a label, etc. • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc
Types of XPath Functions XPath Starts-with () XPath Contains () XPath Text () • The XPath Starts-with() function is used to find the element in which the attribute value starts with some specific character • The function plays a major role while working with the dynamic web pages • The XPath Text() is a function used to locate the element on a web page using the web element's text • The function proves its worth if the element contains a text, like a label, etc. • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc
Types of XPath Functions XPath Starts-with () XPath Contains () XPath Text () • The XPath Starts-with() function is used to find the element in which the attribute value starts with some specific character • The function plays a major role while working with the dynamic web pages • The XPath Text() is a function used to locate the element on a web page using the web element's text • The function proves its worth if the element contains a text, like a label, etc. • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc
Types of XPath Functions XPath Starts-with () XPath Contains () XPath Text () • The XPath Starts-with() function is used to find the element in which the attribute value starts with some specific character • The function plays a major role while working with the dynamic web pages • The XPath Text() is a function used to locate the element on a web page using the web element's text • The function proves its worth if the element contains a text, like a label, etc. • The XPath Contains() is a function used to create an XPath expression • It is used if part of the value of any attribute changes dynamically, like login information, etc /tag_name[starts-with(@attribute,’Part_of_Attribute_value’)]
XPath Axes • XPath Axes makes it possible to search different nodes in XML document from the current node • These are methods used to find dynamic elements which are not possible to be found by normal XPath
XPath Axes • XPath Axes makes it possible to search different nodes in XML document from the current node • These are methods used to find dynamic elements which are not possible to be found by normal XPath
XPath Axes Some of the axes that help in locating the elements on the webpage are: