<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by madhuri kalavala on Medium]]></title>
        <description><![CDATA[Stories by madhuri kalavala on Medium]]></description>
        <link>https://medium.com/@kalavalamadhuri3?source=rss-8b7a15d796dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*akqFgEpmZFCEywvx</url>
            <title>Stories by madhuri kalavala on Medium</title>
            <link>https://medium.com/@kalavalamadhuri3?source=rss-8b7a15d796dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 21:45:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kalavalamadhuri3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Xpath in Selenium]]></title>
            <link>https://medium.com/@kalavalamadhuri3/xpath-in-selenium-413149473add?source=rss-8b7a15d796dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/413149473add</guid>
            <category><![CDATA[xpath-functions]]></category>
            <category><![CDATA[xpath-in-selenium]]></category>
            <category><![CDATA[dynamic-xpath]]></category>
            <category><![CDATA[xpath]]></category>
            <dc:creator><![CDATA[madhuri kalavala]]></dc:creator>
            <pubDate>Wed, 04 May 2022 05:26:52 GMT</pubDate>
            <atom:updated>2022-05-15T16:41:05.033Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>For automating any web Applications, <a href="https://medium.com/@kalavalamadhuri3/selenium-locators-5236a91a1c85"><strong>locating web elements</strong></a>(link for locators in selenium) is first step. We need some unique attributes such as id, name, className etc., to identify the Html elements. Some times we can see Dynamic Web elements, where there are no unique attributes associated with the Web elements and there comes <strong>Xpath </strong>.</blockquote><p>· <strong>What is Xpath?</strong></p><p>· <strong>Basic syntax of Xpath?</strong></p><p>· <strong>What is DOM?</strong></p><p>· · <strong>How to locate Web Elements using Xpath?</strong></p><p>· <strong>What are the different types of xpath &amp; Difference between Absolute xpath and Relative xpath?</strong></p><p>· <strong>Which xpath is preferred and why?</strong></p><p>· <strong>What are Xpath Functions in Selenium?</strong></p><p><strong>1.</strong> <strong>What is Xpath?</strong></p><p>· Xpath is defined as XML Path.</p><p>· It is a syntax for finding any element on the web page Using XML path Expression.</p><p>· It is used to <strong>find the location or address of any element</strong> on a webpage using <strong>HTML DOM Structure.</strong></p><p>· Xpath can be used to navigate through elements &amp; attributes in DOM.</p><p><strong>2.Basic syntax of the XPath</strong> :</p><p>Xpath= //tagname[@Attribute=’value’]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*8Bvg4SAMYFNY7StsH1KXIA.png" /></figure><p>Example:</p><p>driver.findElement(By.xpath(“//input[@id=’email’]”));</p><p>Here we are using the input tag and id attribute to identify the element using xpath. When you want to check our xpath is right or wrong we can use shortcut key <strong>ctrl+f</strong> and we can type there as shown in above image, then it will Show the element in yellow color.</p><p><strong>3.What is DOM?</strong></p><p>DOM is an API Interface provided by browser.</p><p>When a web page is loaded, the browser automatically creates a DOM of the page.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*tzrmEOa77Nbj900LalOyXQ.png" /></figure><p>Generally, in UI will be created in HTML code of the webpage , internally the browser automatically creates DOM Structure. Same HTML will be aligned in the form of <strong>nodes. </strong>Xpath works on DOM</p><p><strong>4.How to locate Web Elements using Xpath?</strong></p><p>We learned about basic syntax of xpath, there we used special characters like”//” and ”@” that helps to locate and select the desired element/node. Similarly, xpath uses path expressions to select nodes in an XML document. The most useful path expressions are listed below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*sICqDTfJQbPDJzkbDT4c1A.png" /></figure><p>5<strong>.What are the different types of xpath?</strong></p><p>There are 2 types of xpath:</p><p>1.Absolute xpath</p><p>2. Relative xpath</p><p>· <strong>Difference between Absolute xpath and Relative xpath?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*5HGRx5zDFoKEh81Hwo_HlQ.png" /></figure><p>Here in the above example, both absolute and relative xpath both specify the same web element but most of the time we prefer Relative xpath.</p><p>6. · <strong>Which xpath is preferred and why?</strong></p><p>We always prefer <strong>Relative xpath</strong> because in Absolute xpath, when the existing elements are removed or new element introduced or existing element moved to some other place then Absolute Xpath is broken and it may not work.</p><p>7· <strong>What are Xpath Functions in Selenium?</strong></p><p>Sometimes while working in a dynamic web Environment, it becomes challenging to locate a particular web element by using general attributes like id, name, class etc. with Basic xpath may not be efficient, in such case we use Xpath Functions</p><p>Xpath provides different functions in selenium, which helps in <strong>locating web element Uniquely</strong></p><p>1. Contains()</p><p>2. Starts-with()</p><p>3. Text()</p><p>4. AND &amp; OR Operator</p><p>5. Using Index</p><p>1.<strong>Contains()</strong> :</p><p>Xpath Contains() is one of the method used while creating an xpath expression. When the value of any attribute changes dynamically, It can locate a web element with the partial text.</p><p>Syntax:</p><p><strong>//tagname[contains(@attribute,’value’)]</strong></p><p>Or</p><p>//*[contains(@attribute,’value’)]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*Ownkpw8V7JtB5foKN3X7hQ.png" /></figure><p>Example:</p><p>//input[@id=’email’] →Basic Xpath</p><p>//input[contains(@id,’email’)] →using contains() method</p><p><strong>→using contains with different attribute and value locate same web element</strong></p><p>//input[contains(@data-testid,’_email’)]</p><p>//*[contains(@data-testid,’email’) or</p><p>//*[contains(@data-testid,’mail’) or</p><p>//*[contains(@data-testid,’royal_e’)]</p><p>In the above examples will specify same web element but we will write using partial value of the attribute in different ways.</p><p>Here we can use specific tagname or we can use Asterisk (*), tagname specifies only input in this example where as if we use * it specifies any tag with the same value.</p><p><strong>//*[contains(@data-testid,’royal’)] →</strong>it won’t find the right web element</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*rol4iuDj_zdK6FhRiWYVTg.png" /></figure><p>Here in the above example, when we are taking @data-testid=”royal”</p><p>Multiple elements have the same value of “data-testid” attribute then it will select the first value in the page which is not the right web element of email textbox, in the snippet we can see <strong>1 of 4</strong> means there with the same value we are able to find 4 elements. <strong>So we always make</strong> <strong>sure the value of the attribute should be unique.</strong></p><p><strong>2.</strong> <strong>starts-with() :</strong></p><p>The Xpath starts-with() method, finds the element which has attribute value starting with the specific character or character sequence. This function is useful while dealing with <strong>dynamic web pages</strong>.</p><p>For example, Imagine an element that has an attribute value that keeps on changing every time when page is loaded or refreshed, in that case dynamic elements have few common starting characters, followed by dynamic texts</p><p><strong>Syntax:</strong></p><p><strong>//tagname[starts-with(@attribute,’value’)]</strong></p><p>Or //*[<strong> </strong>starts-with (@attribute,’value’)]</p><p>Example:</p><p>//input[starts-with (@id,’email’)]</p><p>Or</p><p>//input[starts-with (@id,’ema’)] — → valid</p><p>//input[starts-with (@id,’mail’)] — -&gt; INvalid</p><p>Starts-with() as the name says always starts from starting of the value. For this function, we can’t write middle characters, it will be Invalid.</p><p>3.<strong>text()</strong> :</p><p>This function uses the <strong>text of the web element</strong> for locating the element on the web page. It helps to find the exact text elements and it locates the elements within the set of text nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*mEOwhnt62IZLznkww6jsqA.png" /></figure><p><strong>Syntax:</strong></p><p><strong>//tagname[text()=’value’)]</strong></p><p><strong>Example: </strong>//a[text()=’Women’]</p><p>or</p><p>//*[text()=’Women’] — → valid xpath</p><p>//a[text()=’Wom’] — — -&gt; Invalid xpath</p><p>In the above example, while using text() Function we should give complete value of the text then its valid when we give partial value of text it becomes invalid.</p><p>· <strong>Contains() &amp; text():</strong></p><p>Here we are using contains() &amp; text() functions together in one xpath.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*4ULV530ydqrq5KuBg3Sv2g.png" /></figure><p>Syntax<strong>: //*[contains(text(),’value’)]</strong></p><p>Example: //a[contains(text(),’wom’)]</p><p>While using contains() &amp; text() as one xpath, here we can give partial value of the text. Basically, we use this whenever there is long text.</p><p>4.<strong>AND &amp; OR Operator:</strong></p><p>The <strong>and </strong>Operator is used to combine two or more attributes to identify any element from a webpage using Xpath efficiently. Suppose, If we have two attributes A &amp; B, we can combine both to identify an element uniquely on the webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*kN4-yOHD-DNxcW_S-k67iw.png" /></figure><p><strong>Example: </strong>//*[@name=’email’ and @id=’email’]</p><p>//input[@name=’email’ and @id=’email’]</p><p>In this example, we are using name and id attribute to locate the element , you can use any attribute required to identify the element uniquely. When <strong>Both the conditions</strong>(attribute values) <strong>are</strong> <strong>true ,</strong>then only it can locate the element.</p><p>The <strong>or </strong>operator is used to locate an element based on any one of the conditions segregated by the <strong>or </strong>operator. We use it majorly based on certain run-time conditions. If we have two attributes A &amp; B, in this at least one either A or B needs to match then it can identify an element uniquely on the webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*EdGWdGP8mwcZHLxs69uoYw.png" /></figure><p><strong>Example: </strong>//*[@name=’email’ or @id=’email2’]</p><p>//input[@name=’email’ or @id=’email2&#39;]</p><p>In this example, we are using name and id attribute to locate the element , you can use any attribute required to identify the element uniquely. When <strong>at least one condition</strong>(attribute values either name or id) <strong>should be true ,</strong>then only it can locate the element.</p><p>Here, name attribute is matching the value but id is not matching the attribute value, even though its locating the element.</p><p><strong>5.Using Index :</strong></p><p>This approach comes in use when you wish to specify a tagname in terms of index value you wish to locate. As well when there are more than one element matching with same xpath by the time we use index to identify element uniquely.</p><p>Syntax: (//*[@attribute=’value’])[index]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*D8bk1JTs8zfrj3ewRX8kkw.png" /></figure><p>In the above snippet, we can notice while writing xpath for <strong>Dresses </strong>we are able to see <strong>1 0f 21</strong>, when we want to identify <strong>unique element</strong> in such cases, we use index. By default it locates first element.</p><p>Actually, I want to select casual dresses xpath in such case we can use as follows:</p><p>Example:(//a[contains(text(),’Dresses’)])[2]</p><p>You can clearly understand by seeing snippet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*JjaeLgvSoWm0_GGjLe6l1A.png" /></figure><p>Sometimes even after using above functions, the user is not able to locate the web elements uniquely. In such Scenarios, the <strong>Xpath axes</strong> comes in selenium.</p><p>Do look out for other articles in this series which will explain the various other aspects of selenium.</p><p>. <a href="http://2.https//medium.com/@kalavalamadhuri3/selenium-locators-5236a91a1c85">Locators in selenium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=413149473add" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selenium Locators]]></title>
            <link>https://medium.com/@kalavalamadhuri3/selenium-locators-5236a91a1c85?source=rss-8b7a15d796dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/5236a91a1c85</guid>
            <category><![CDATA[locators-in-selenium]]></category>
            <category><![CDATA[selenium-locators]]></category>
            <dc:creator><![CDATA[madhuri kalavala]]></dc:creator>
            <pubDate>Thu, 14 Apr 2022 23:40:38 GMT</pubDate>
            <atom:updated>2022-05-04T05:31:27.868Z</atom:updated>
            <content:encoded><![CDATA[<p>As an Automation tester, we all know that for testing web-based applications, we need to perform specific actions on the HTML elements. While we do automation on applications, automation tools should be capable of performing the same operations on the HTML elements that a human is capable of.</p><p>Here comes a question, how do these automation tools identifies on which element they have to perform a specific operation?</p><p>Answer is so simple using “<strong>Locators in Selenium”</strong></p><p>· What are Locators in Selenium?</p><p>· How to Locate a Web element in DOM?</p><p>· Types of Locators?</p><p><strong>What are Locators in Selenium?</strong></p><p>Locators defines “<strong>an address that identifies the web elements uniquely”</strong> on the web page. We use locators to access the HTML elements from a web page. We can use locators to perform actions on textboxes, checkboxes, links, radio buttons and other web elements.</p><p><strong>How to Locate a Web element in DOM?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*4bdibmf48BPGGD_Wg4ImLw.png" /></figure><p>To find the HTML element in <strong>DOM </strong>(Document Object Model), we need to use a locator. Steps to identifying the web element in DOM on a web browser:</p><p>· Right click on the web page and click on <strong>inspect </strong>option.</p><p>· BY default, it will open the <strong>Elements </strong>tab(right side as shown in screenshot), Which represents the complete DOM structure of the web page. If we hover the mouse pointer over the Html tags in the DOM, it will highlight the corresponding element on the web page.</p><p>· To find the web element in DOM click on the <strong>Mouse Icon</strong> (right side page on the top corner with orange arrow) and then select the web element on the web page. It automatically highlights the corresponding HTML element in DOM.</p><p><strong>Types of Locators?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*CmeUl15Ttdbwx_RuTpdB_Q.png" /></figure><p>There are 8 different locators as shown in the above image which are used to identify a web element uniquely on the web page. To access all these locators, selenium provides <strong>By </strong>class, which helps in locating elements within DOM. Here we have Locators and customized locators:</p><p>· Locators are id, name, Link text, partial link text, classname, tagname.</p><p>· Customized locators are CSS Selector and Xpath.</p><p>Before going to know in detail about locators lets see one sample example to know what are tagname, attribute and value.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*SmFo3p6ASwtgFdWT9shAEQ.png" /></figure><p>Here in this example input is tagname, class &amp;name are attribute, inputtext &amp; email are values.</p><p><strong>1. Locating By “id”:</strong></p><p>This is the most common way of locating elements considering that they are unique to each element in DOM. Based on W3C, id for a web element always needs to be unique. <strong>Id</strong> is one of the fastest and unique way of locating web elements. But sometimes we see <strong>dynamic ids</strong> are generated for dynamic web pages that time we don’t prefer to use id attribute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*BEL09mF5b0ADsrjjtzCmvA.png" /><figcaption>facebook.com</figcaption></figure><p>&lt;input type=”text” class=” inputtext_55rl_6luy” name=” email” id=”email”&gt;</p><p>HTML tag contains attribute “id” in the input tag. Here <strong>id =”email” </strong>which<strong> </strong>we<strong> </strong>use to locate the element in the web page for email textbox as shown above.</p><p>Example: <strong>driver.findElement(By.id(“email”));</strong></p><p><strong>2. Locating By “name”:</strong></p><p>An element can be defined by using multiple attributes, one such element is <strong>“name”. </strong>locating elements by Name are very similar to id. They may or may not have unique value, if multiple elements have the same value of “name” attribute then it will select the first value in the page. So we always make sure the value of the attribute should be unique.</p><p>In case no such name matches with the defined attribute value, it shows NoSuchElementFound Exception.</p><p>Example:</p><p>&lt;input type=”text” class=” inputtext_55rl_6luy” <strong>name=” email”</strong> id=”email”&gt;</p><p>HTML tag contains attribute “name” in the input tag. Here <strong>name =”email” </strong>which<strong> </strong>we<strong> </strong>use to locate the element in the web page for email textbox as shown above.</p><p>Example: <strong>driver.findElement(By.name(“email”)); //vaiid</strong></p><p><strong>driver.findElement(By.name(“eail”)); //NoSuchElementFound</strong></p><p>Here in this example we are providing invalid attribute value as “eail” In such cases selenium shows NoSuchElementFound.</p><p><strong>3.Locating By “className”:</strong></p><p>Class Name locator is used for locating web element through “<strong>class” </strong>attribute</p><p>Example:</p><p>&lt;input type=”text<strong>” class=” inputtext_55rl_6luy”</strong> name=” email” id=”email”&gt;</p><p>HTML tag contains attribute “name” in the input tag. Here <strong>class=”</strong>inputtext_55rl_6luy<strong>” </strong>which<strong> </strong>we<strong> </strong>use to locate the element in the web page for email textbox as shown above.</p><p><strong>driver.findElement(By.className(“inputtext_55rl_6luy”));</strong></p><p><strong>4.Locating By “linktext” and “partialLinkText”:</strong></p><p>Linktext and partialLinkText both are similar in functionality as well they are case-sensitive and used for hyperlink text use them for elements containing anchortag&lt;a&gt;. In single page we can find multiple hyperlinks with the same text in such case selenium always choose first element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*cfeKaO90n5GPLvZNelG8zA.png" /></figure><p>When we inspect on sign In it’s a hyperlink so its starting with &lt;a&gt;</p><p>&lt;a class=”login” href=”http://automationpractice.com/index.php?controller=my-account&quot;”&gt;<strong>Sign in</strong>&lt;/a&gt;</p><p><strong>LinkText Example:</strong></p><p><strong>driver.findElement(By.linkText(“Sign in”));</strong></p><p><strong>partialLinkText Example:</strong></p><p><strong>driver.findElement(By.partialLinkText(“Sign ”));</strong></p><p>They both are similar in functionality but minor difference is for linktext we have to use complete text whereas for partial link text we use</p><p>Part of the text. Basically we use partial text only when we have a long link text</p><p><strong>5.Locating By “tagName”:</strong></p><p>TagName is used to identify elements in a web page such as</p><p>Input, div, anchor tag(a), buttons etc., It is very helpful when we want to search how many links in a webpage or anything like how many input tags are there.</p><p>As well we use this tagname in CSS Selector and xpath</p><p>Tag name locator is commonly used to identify all the links on a page and identify “<strong>broken links”</strong> in selenium</p><p>Example: <strong>driver.findElements(By.tagName(“a”)).size();</strong></p><p>In the above example it shows how many anchor tags are available in the specific web page</p><p><strong>6.Locating By “CSS Selector”:</strong></p><p>CSS(Cascading Style Sheets) is used to style web pages. CSS selector in selenium should be opted if you can’t locate an element by using unique id, name or class.. in this type of situation we use CSS Selector or xpath</p><p>Here are different ways we can use CSS Selector in selenium:</p><p>1. Tag &amp; id (OR) #id</p><p>2. Tag &amp; class (OR) .class</p><p>3. Tag &amp; attribute (OR) [attribute=value]</p><p>4. Tag, class &amp; attribute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*lru8_yiS_MGPnewmIIwtIA.png" /></figure><p>By using above example(screenshot) we will write different ways how we can use CSS Selector</p><p>1. <strong>Tag &amp; id (OR) #id :</strong></p><p>· Tag: it provides tag name we wish to locate(input).</p><p>· # : it is used to represent id attributes. When we wish to locate <strong>id </strong>through <strong>CSS Selector</strong> ,it must have a hash sign(#) only for id.</p><p>· Value of the id<strong> </strong>attribute: used to locate element.</p><p><strong>Syntax: css=(Html tag)(#)(value of the id attribute)</strong></p><p><strong>Example:</strong></p><p>&lt;input type=”text” class=” inputtext_55rl_6luy” name=” email” <strong>id=”email</strong>”&gt;</p><p>driver.findElement(By.cssSelector(“input#email”));</p><p>or</p><p>driver.findElement(By.cssSelector(“#email”));</p><p>here in this example first we used <strong>tag#id</strong> combination and in the next example we used only #id both works same in functionality.</p><p><strong>2.Tag &amp; class (OR) .class :</strong></p><p>It is similar to id, here instead of # we use <strong>.(dot)</strong>, when using class through CSS Selector, it must have .(dot) for class attribute.</p><p><strong>Syntax: css = (Html tag)(.)( value of class attribute)</strong></p><p>Example:</p><p>&lt;input type=”text” <strong>class=” inputtext</strong>_55rl_6luy” name=” email” id=”email”&gt;</p><p>driver.findElement(By.cssSelector(“input.inputtext”));</p><p>or</p><p>driver.findElement(By.cssSelector(“.inputtext”));</p><p>Here in this example first we used <strong>tag.class</strong> value combination and in the next example we used only <strong>.class</strong> value both works the same in functionality. Here we no need to use value we use only text for class value.</p><p>3. <strong>Tag &amp; Attribute :</strong></p><p>The elements can be located via tagname, and the corresponding attribute is defined using its value. Incase multiple elements have the same tag &amp; attribute, it will take first one will be selected.</p><p><strong>Syntax: css = (Html tag)[Attribute= value]</strong></p><p>Example:</p><p>&lt;input type=”text” class=” inputtext_55rl_6luy”<strong> name=” email</strong>” id=”email”&gt;</p><p>driver.findElement(By.cssSelector(“input[name=email]”);</p><p>or</p><p>driver.findElement(By.cssSelector(“[name=email]”);</p><p>4. <strong>Tag, Class &amp; Attribute : </strong>When we have same tagname &amp; same class name at that time we use attribute along with class &amp; tag name.</p><p><strong>Syntax: css = (Html tag)(.)(Class attribute value)[Attribute= value]</strong></p><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*pDP8pdNpF0oLFuuRhOdiOg.png" /></figure><p>//for email</p><p>driver.findElement</p><p>(By.cssSelector(“input.inputtext[data_testid=royal_email]”);</p><p>//for password</p><p>driver.findElement</p><p>(By.cssSelector(“input.inputtext[data-testid=royal_pass]”);</p><p>In the above example we can see that tagname and class name are same for both email and password in such cases we are taking Attribute, so that they will be unique.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*0T1mg9fxtEtg3Q88uxUgTA.png" /></figure><p><strong>7.Locating By “xpath”:</strong></p><p>Xpath uses the XML expression to locate an element on the webpage using HTML DOM Structure. Similar to CSS selector, xpath is more useful for locating dynamic elements on a webpage. It can access any element present in the web page.</p><p>The basic syntax :</p><p>Xpath= //tagname[@Attribute=’value’]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*JcewKzkz_7lxKcaghR_dQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*8ZD4twqw96T4oMv8cJIJpA.png" /></figure><p>Example:</p><p>driver.findElement(By.xpath[“//input[@id=’email”]);</p><p>Here we are using the input tag and id attribute to identify the element using xpath. When you want to check our xpath is right or wrong we can use shortcut key <strong>ctrl+f</strong> and we can type there as shown in above image, then it will Show the element in yellow color .</p><p><strong>We will cover more depth in details about “xpath locator” strategies to identify various web elements in another article.</strong></p><p>Do look out for other articles in this series which will explain the various other aspects of selenium.</p><p><a href="https://medium.com/@kalavalamadhuri3/xpath-in-selenium-413149473add">Xpath in Selenium</a></p><p><a href="https://medium.com/@kalavalamadhuri3/xpath-in-selenium-413149473add">XPath Functions</a></p><p><a href="https://medium.com/@kalavalamadhuri3/xpath-in-selenium-413149473add">Difference between Absolute Xpath &amp; Relative Xpath</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5236a91a1c85" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>