{"id":681,"date":"2019-12-05T13:32:16","date_gmt":"2019-12-05T08:02:16","guid":{"rendered":"http:\/\/http:\/\/artoftesting.com\/\/?p=681"},"modified":"2023-07-10T13:05:46","modified_gmt":"2023-07-10T07:35:46","slug":"xpath-in-selenium-tutorial","status":"publish","type":"post","link":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial","title":{"rendered":"XPath Tutorial &#8211; XPath in Selenium and Other Automated Tools"},"content":{"rendered":"\n<p>In this xPath tutorial, we are going to study the usage of the XPath locator in Selenium WebDriver and other automated tools. In our post on\u00a0finding WebElements in Selenium, we studied different types of <a href=\"http:\/\/artoftesting.com\/locators-in-selenium-webdriver\">locators used in Selenium WebDriver<\/a>. <br><br>Here, we will be studying how to create Xpath locators, the different types of Xpaths, and the ways of finding dynamic elements using XPath. Writing XPaths is also one of the most frequently asked <a href=\"http:\/\/artoftesting.com\/selenium-interview-questions\">Selenium interview questions<\/a>. So, practice this throughly for both automation as well as interview preparation point of view.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-flat ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Content<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\/#What_is_an_XPath\" title=\"What is an XPath?\">What is an XPath?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\/#What_are_the_different_types_of_XPath\" title=\"What are the different types of XPath?\">What are the different types of XPath?<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\/#Finding_Dynamic_Elements_using_XPaths\" title=\"Finding Dynamic Elements using XPaths\">Finding Dynamic Elements using XPaths<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\/#Using_text\" title=\"Using text()\">Using text()<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\/#Using_contains\" title=\"Using contains()\">Using contains()<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\/#Using_the_elements_index\" title=\"Using the element&#8217;s index\">Using the element&#8217;s index<\/a><\/li><li class='ez-toc-page-1'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\/#Using_XPath_axes\" title=\"Using XPath axes\">Using XPath axes<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_an_XPath\"><\/span>What is an XPath?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>An XPath can be defined as a query language used for navigating through XML documents in order to locate different elements. The basic syntax of an XPath expression is-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; gutter: false; title: ; notranslate\" title=\"\">\n\/\/tag&#x5B;@attributeName='attributeValues']\n<\/pre><\/div>\n\n\n<p>Now, let&#8217;s understand the different elements in the Xpath expression syntax &#8211; tag, attribute, and attribute values using an example. Consider the below image of the Google <a href=\"http:\/\/artoftesting.com\/what-is-a-webpage\">webpage<\/a> with Firebug inspecting the Search-bar div.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"856\" height=\"391\" src=\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/xpath.jpg\" alt=\"Xpath Tutorial\" class=\"wp-image-682\" srcset=\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/xpath.jpg 856w, https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/xpath-300x137.jpg 300w, https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/xpath-768x351.jpg 768w\" sizes=\"auto, (max-width: 856px) 100vw, 856px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&#8216;\/&#8217; or &#8216;\/\/&#8217;<\/strong>\u00a0&#8211; The single slash and double slash are used to create absolute and relative XPaths(explained later in this tutorial). A single slash is used to start the selection from the root node. Whereas, the double slash is used to fetch the current node matching the selection. For now, we will be using &#8216;\/\/&#8217; here.<\/li>\n\n\n\n<li><strong>Tag<\/strong>&nbsp;&#8211; Tags in HTML begin with &#8216;&lt;&#8216; and end with &#8216;&gt;&#8217;. These are used to enclose different elements and provide information about the processing of the elements. In the above image, &#8216;div&#8217; and &#8216;input&#8217; are tags.<\/li>\n\n\n\n<li>Attribute&nbsp;&#8211; Attributes define the properties that the HTML elements hold. In the above image, id, classes, and dir are the attributes of the outer div.<\/li>\n\n\n\n<li><strong>AttrbuteValue<\/strong>&nbsp;&#8211; AttributeValues as the name suggest, are the values of the attributes e.g. &#8216;sb_ifc0&#8217; is the attribute value of &#8216;id&#8217;.<\/li>\n<\/ul>\n\n\n\n<p>Using the XPath syntax displayed above, we can create multiple XPath expressions for the Google search bar &#8211; div given in the image like-\u00a0<\/p>\n\n\n\n<p><strong>\/\/div[@id=&#8217;sb_ifc0&#8242;]<\/strong>,\u00a0<strong>\/\/div[@class=&#8217;sbib_b&#8217;]<\/strong>\u00a0or\u00a0<strong>\/\/div[@dir=&#8217;ltr&#8217;]<\/strong>. Any of these expressions can be used to fetch the desired element as long as the attributes chosen are unique.<br><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_are_the_different_types_of_XPath\"><\/span>What are the different types of XPath?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are two kinds of XPath expressions-<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Absolute XPath<\/strong>\u00a0&#8211; The XPath expressions created using absolute XPaths begin the selection from the root node. These expressions either begin with the &#8216;\/&#8217; or the root node and traverse the whole DOM to reach the element.<\/li>\n\n\n\n<li><strong>Relative XPath<\/strong>&nbsp;&#8211; The relative XPath expressions are a lot more compact and use forward double slashes &#8216;\/\/&#8217;. These XPaths can select the elements at any location that matches the selection criteria and doesn&#8217;t necessarily begin with the root node.<\/li>\n<\/ol>\n\n\n\n<p>So, which one of the two is better?- The relative XPaths are considered better because these expressions are easier to read and create, and also more robust. The problem with absolute XPaths is, even a slight change in the DOM from the path of the root node to the desired element can make the XPath invalid.<br><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Finding_Dynamic_Elements_using_XPaths\"><\/span>Finding Dynamic Elements using XPaths<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Many times in automation, we either don&#8217;t have unique attributes of the elements that uniquely identify them or the elements are dynamically generated with the attribute&#8217;s value not known beforehand. <br><br>For cases like these, XPath provides different methods of locating elements &#8211; using the text written over the elements; using the element&#8217;s index; using partially matching attribute value; by moving to a sibling, child, or parent of an element that can be uniquely identified, etc.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_text\"><\/span><strong>Using text()<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Using text(), we can locate an element based on the text written over it e.g. XPath for the &#8216;Google Search&#8217; button &#8211;<br><strong>\/\/*[text()=&#8217;Google Search&#8217;]<\/strong>\u00a0\u00a0\u00a0(we used &#8216;*&#8217; here to match any tag with the desired text)<br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_contains\"><\/span><strong>Using contains()<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The contains(), we can match even the values of the partially matching attributes. This is particularly helpful for locating dynamic values whose some part remains constant e.g. XPath for the outer div in the above image having id as &#8216;sb_ifc0&#8217; can be located even with partial id-&#8216;sb&#8217; using contains() &#8211;&nbsp;<strong>\/\/div[contains(@id,&#8217;sb&#8217;)]<\/strong><br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_the_elements_index\"><\/span><strong>Using the element&#8217;s index<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>By providing the index position in the square brackets, we can move to the nth element satisfying the condition e.g.&nbsp;<strong>\/\/div[@id=&#8217;elementid&#8217;]\/input[4]<\/strong>&nbsp;will fetch the fourth input element inside the div element.<br><br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Using_XPath_axes\"><\/span><strong>Using XPath axes<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>XPath axes help in locating complex web elements by traversing them through a sibling, child or parent of other elements that can be identified easily. Some of the widely used axes are-<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>child<\/strong><\/td><td>To select the child nodes of the reference node. <br>Syntax &#8211; XpathForReferenceNode\/child::tag<\/td><\/tr><tr><td><strong>parent<\/strong><\/td><td>To select the parent node of the reference node. <br>Syntax &#8211; XpathForReferenceNode\/parent::tag<\/td><\/tr><tr><td><strong>following<\/strong><\/td><td>To select all the nodes that come after the reference node. <br>Syntax &#8211; XpathForReferenceNode\/following::tag<\/td><\/tr><tr><td><strong>preceding<\/strong><\/td><td>To select all the nodes that come before the reference node. <br>Syntax &#8211; XpathForReferenceNode\/preceding::tag<\/td><\/tr><tr><td><strong>ancestor<\/strong><\/td><td>To select all the ancestor elements before the reference node. <br>Syntax &#8211; XpathForReferenceNode\/ancestor::tag<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For a complete step-by-step <a href=\"http:\/\/artoftesting.com\/selenium-tutorial\">Selenium tutorial<\/a>, you can refer to the below link-<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"http:\/\/artoftesting.com\/selenium-tutorial\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"172\" src=\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/selenium-tutorial-small.jpg\" alt=\"Selenium Tutorial\" class=\"wp-image-734\"\/><\/a><\/figure><\/div>\n\n\n<p>This concludes our XPath tutorial on the usage of XPath in Selenium and other tools.  I hope with this tutorial you will be able to locate both static and dynamic elements using XPath. Happy learning!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this xPath tutorial, we are going to study the usage of the XPath locator in Selenium WebDriver and other automated tools. In our post on&nbsp;finding WebElements in Selenium, we studied different types of locators used in Selenium WebDriver. Here, we will be studying how to create Xpath locators, the different types of Xpaths, and &#8230; <a title=\"XPath Tutorial &#8211; XPath in Selenium and Other Automated Tools\" class=\"read-more\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\" aria-label=\"Read more about XPath Tutorial &#8211; XPath in Selenium and Other Automated Tools\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":1716,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-681","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selenium"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Selenium xpath tutorial - locate elements using Xpath in selenium webDriver<\/title>\n<meta name=\"description\" content=\"Xpath tutorial, learn xpath locators in Selenium WebDriver with Java.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Selenium xpath tutorial - locate elements using Xpath in selenium webDriver\" \/>\n<meta property=\"og:description\" content=\"Xpath tutorial, learn xpath locators in Selenium WebDriver with Java.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\" \/>\n<meta property=\"og:site_name\" content=\"ArtOfTesting\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/artoftesting\" \/>\n<meta property=\"article:published_time\" content=\"2019-12-05T08:02:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-10T07:35:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kuldeep Rana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@theartoftesting\" \/>\n<meta name=\"twitter:site\" content=\"@theartoftesting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kuldeep Rana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#article\",\"isPartOf\":{\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\"},\"author\":{\"name\":\"Kuldeep Rana\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5\"},\"headline\":\"XPath Tutorial &#8211; XPath in Selenium and Other Automated Tools\",\"datePublished\":\"2019-12-05T08:02:16+00:00\",\"dateModified\":\"2023-07-10T07:35:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\"},\"wordCount\":917,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/artoftesting.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage\"},\"thumbnailUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg\",\"articleSection\":[\"Selenium\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\",\"url\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\",\"name\":\"Selenium xpath tutorial - locate elements using Xpath in selenium webDriver\",\"isPartOf\":{\"@id\":\"https:\/\/artoftesting.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage\"},\"thumbnailUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg\",\"datePublished\":\"2019-12-05T08:02:16+00:00\",\"dateModified\":\"2023-07-10T07:35:46+00:00\",\"description\":\"Xpath tutorial, learn xpath locators in Selenium WebDriver with Java.\",\"breadcrumb\":{\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage\",\"url\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg\",\"contentUrl\":\"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg\",\"width\":700,\"height\":400,\"caption\":\"selenium xpath\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/artoftesting.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Automation Testing\",\"item\":\"https:\/\/artoftesting.com\/category\/automation-testing\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Selenium\",\"item\":\"https:\/\/artoftesting.com\/category\/automation-testing\/selenium\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"XPath Tutorial &#8211; XPath in Selenium and Other Automated Tools\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/artoftesting.com\/#website\",\"url\":\"https:\/\/artoftesting.com\/\",\"name\":\"ArtOfTesting\",\"description\":\"A Beginners Guide to Testing\",\"publisher\":{\"@id\":\"https:\/\/artoftesting.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/artoftesting.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/artoftesting.com\/#organization\",\"name\":\"ArtOfTesting\",\"url\":\"https:\/\/artoftesting.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png\",\"contentUrl\":\"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png\",\"width\":400,\"height\":60,\"caption\":\"ArtOfTesting\"},\"image\":{\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/artoftesting\",\"https:\/\/x.com\/theartoftesting\",\"https:\/\/www.linkedin.com\/groups\/4797819\/\",\"https:\/\/in.pinterest.com\/artoftesting\/\",\"https:\/\/www.youtube.com\/channel\/UCQ9PUVenvvyrUdDQ9yKn31Q\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5\",\"name\":\"Kuldeep Rana\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/artoftesting.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g\",\"caption\":\"Kuldeep Rana\"},\"description\":\"Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Selenium xpath tutorial - locate elements using Xpath in selenium webDriver","description":"Xpath tutorial, learn xpath locators in Selenium WebDriver with Java.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial","og_locale":"en_US","og_type":"article","og_title":"Selenium xpath tutorial - locate elements using Xpath in selenium webDriver","og_description":"Xpath tutorial, learn xpath locators in Selenium WebDriver with Java.","og_url":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial","og_site_name":"ArtOfTesting","article_publisher":"https:\/\/facebook.com\/artoftesting","article_published_time":"2019-12-05T08:02:16+00:00","article_modified_time":"2023-07-10T07:35:46+00:00","og_image":[{"width":700,"height":400,"url":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg","type":"image\/jpeg"}],"author":"Kuldeep Rana","twitter_card":"summary_large_image","twitter_creator":"@theartoftesting","twitter_site":"@theartoftesting","twitter_misc":{"Written by":"Kuldeep Rana","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#article","isPartOf":{"@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial"},"author":{"name":"Kuldeep Rana","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5"},"headline":"XPath Tutorial &#8211; XPath in Selenium and Other Automated Tools","datePublished":"2019-12-05T08:02:16+00:00","dateModified":"2023-07-10T07:35:46+00:00","mainEntityOfPage":{"@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial"},"wordCount":917,"commentCount":2,"publisher":{"@id":"https:\/\/artoftesting.com\/#organization"},"image":{"@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage"},"thumbnailUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg","articleSection":["Selenium"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#respond"]}]},{"@type":"WebPage","@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial","url":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial","name":"Selenium xpath tutorial - locate elements using Xpath in selenium webDriver","isPartOf":{"@id":"https:\/\/artoftesting.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage"},"image":{"@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage"},"thumbnailUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg","datePublished":"2019-12-05T08:02:16+00:00","dateModified":"2023-07-10T07:35:46+00:00","description":"Xpath tutorial, learn xpath locators in Selenium WebDriver with Java.","breadcrumb":{"@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/artoftesting.com\/xpath-in-selenium-tutorial"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#primaryimage","url":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg","contentUrl":"https:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/XPath-selenium.jpg","width":700,"height":400,"caption":"selenium xpath"},{"@type":"BreadcrumbList","@id":"https:\/\/artoftesting.com\/xpath-in-selenium-tutorial#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/artoftesting.com\/"},{"@type":"ListItem","position":2,"name":"Automation Testing","item":"https:\/\/artoftesting.com\/category\/automation-testing"},{"@type":"ListItem","position":3,"name":"Selenium","item":"https:\/\/artoftesting.com\/category\/automation-testing\/selenium"},{"@type":"ListItem","position":4,"name":"XPath Tutorial &#8211; XPath in Selenium and Other Automated Tools"}]},{"@type":"WebSite","@id":"https:\/\/artoftesting.com\/#website","url":"https:\/\/artoftesting.com\/","name":"ArtOfTesting","description":"A Beginners Guide to Testing","publisher":{"@id":"https:\/\/artoftesting.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/artoftesting.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/artoftesting.com\/#organization","name":"ArtOfTesting","url":"https:\/\/artoftesting.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/","url":"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png","contentUrl":"http:\/\/artoftesting.com\/wp-content\/uploads\/2019\/12\/Artoftesting_logo.png","width":400,"height":60,"caption":"ArtOfTesting"},"image":{"@id":"https:\/\/artoftesting.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/artoftesting","https:\/\/x.com\/theartoftesting","https:\/\/www.linkedin.com\/groups\/4797819\/","https:\/\/in.pinterest.com\/artoftesting\/","https:\/\/www.youtube.com\/channel\/UCQ9PUVenvvyrUdDQ9yKn31Q"]},{"@type":"Person","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/7846d06225b52c778d160becf65996a5","name":"Kuldeep Rana","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/artoftesting.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cb5979a4b81ca7739c75080e473fad391a8665364e72abaddec9002dd4553326?s=96&d=mm&r=g","caption":"Kuldeep Rana"},"description":"Kuldeep is the founder and lead author of ArtOfTesting. He is skilled in test automation, performance testing, big data, and CI-CD. He brings his decade of experience to his current role where he is dedicated to educating the QA professionals."}]}},"_links":{"self":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/comments?post=681"}],"version-history":[{"count":3,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/681\/revisions"}],"predecessor-version":[{"id":7297,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/posts\/681\/revisions\/7297"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/media\/1716"}],"wp:attachment":[{"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/media?parent=681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/categories?post=681"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artoftesting.com\/wp-json\/wp\/v2\/tags?post=681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}