<?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 Archana on Medium]]></title>
        <description><![CDATA[Stories by Archana on Medium]]></description>
        <link>https://medium.com/@sawantarchna?source=rss-28ed62a3a7ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QJ40hFUj2YZwSwVY0b6B_w.jpeg</url>
            <title>Stories by Archana on Medium</title>
            <link>https://medium.com/@sawantarchna?source=rss-28ed62a3a7ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 01:26:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sawantarchna/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[Find XPath in Chrome Browser for Selenium WebDriver]]></title>
            <link>https://medium.com/@sawantarchna/find-xpath-in-chrome-browser-for-selenium-webdriver-f92346096d77?source=rss-28ed62a3a7ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/f92346096d77</guid>
            <dc:creator><![CDATA[Archana]]></dc:creator>
            <pubDate>Tue, 21 Sep 2021 19:17:23 GMT</pubDate>
            <atom:updated>2021-09-21T19:17:23.905Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is XPath</strong></p><p>XPath is define as XML path. It is a syntax or language for finding any element on the web page using the XML path expression. XPath is used to find the location of any element on a webpage using HTML DOM structure.</p><p>The <strong>Document Object Model</strong> (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.</p><p><strong>Syntax for XPath</strong></p><p>XPath contains the path of the element situated on the web page. Standard syntax for creating XPath is as follows:</p><p>XPath=//tagname[@attribute=’value’]</p><ul><li>// : Select current node.</li><li>Tagname: Tagname of the particular node.</li><li>@: Select attribute.</li><li>Attribute: Attribute name of the node.</li><li>Value: Value of the attribute.</li></ul><p><strong>We will cover here three parts:</strong></p><p>1. Find XPath in Chrome by using ID Locator</p><p>2. How to use Pipeline Operator “|”</p><p>3. How to use Parenthesis () Index</p><p>We are using OrangeHRMlive application</p><p>For reference — <a href="https://opensource-demo.orangehrmlive.com/">https://opensource-demo.orangehrmlive.com/</a></p><p><strong>1) Find XPath in Chrome Browser</strong></p><p>Here we have two options for XPath either we can do right click on the web page and click inspect or we can press F12. After that, you will be able to see details of any of the web elements.</p><p>Let’s go with inspect way, right-click on the username box then you can see at the bottom the elements and different options to see the XPath.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-hzATXiZWBWemL4n6vUd4g.png" /><figcaption>Arrow Button</figcaption></figure><p>Here on the above image, you can see the “Arrow button” (select an element in the page to inspect it) click on it. Then you will find the details of the web element. And press “ctrl+F”, another small bar will open to the bottom “Find by String, Selector or XPath”. Here you can write XPath.</p><p>Let’s write our own XPath for the username box by using “ID Locator”. Here the XPath is “//input[@id=”txtUsername”] if you see below in CTRL+F bar the 1 of 1, it means we found one matching XPath.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yyRyU-0QKOEvHPOr9n-78w.png" /></figure><p>If we use one more way to find from input “type” button. Here XPath will be “//input[@type=”text”]” and we will get 1 of 2, which means we found two matching XPath. This way you can write XPath and you will be able to find web elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNS7Cjd1ir5KMTrNDO93Sg.png" /></figure><p><strong>2) Pipeline Operator “|”</strong></p><p>This is a very important operator for daily scripting. Here we can combine two XPath in one by using Pipeline Operator. So, it will act either first one or the other second one.</p><p>If you are running your script in multiple environments sometimes locators will change. So you do not have to change all the previous locators you can write the new locator as well and you can create a Pipeline Operator. It is behaving like a “or” operator either this or that whichever will work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHnCmvE8Vxy11rAzuIPs2A.png" /></figure><p><strong>3) Using Parenthesis () Index</strong></p><p>If you writing XPath which is matching with multiple nodes. So despite going through the Java Code Iterate the second element, the third element. We can customize our XPath using this “Parenthesis () Index” approach.</p><p>In the below image you will see multiple window examples. In this case, you can see three links with the same name. If you inspect you will see the same text. For this, we will write XPath by using Parenthesis () Index,</p><p>(//*[text]=’Click this link to start new Tab’)[1]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*kV-yodtQYenOGBn3zW1J8Q.png" /></figure><p>So if you see the above image we are getting three same XPath. In this case, if we want to choose one specific XPath. We have to use “Parenthesis” at the beginning and last and give the number of an index in brackets after Parenthesis.</p><p>For example,</p><p>(//*[text()=’Click this link to start new Tab’])[1]</p><p>(//*[text()=’Click this link to start new Tab’])[2]</p><p>(//*[text()=’Click this link to start new Tab’])[3]</p><p>So whenever you are finding multiple matching nodes use this indexing approach and you can easily work to the number of web elements.</p><p><strong>Here we learn</strong>,</p><p>· How to find XPath by inspecting or press F12 you will get the inspector</p><p>· Press “CTRL+F” you will get a small bar where you can write your own XPath</p><p>· Use “Pipeline Operator” for multiple XPath</p><p>· Use “Parenthesis Index” if you have multiple web elements</p><p>Happy Learning!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f92346096d77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Read Data from Excel File # Apache POI in Selenium]]></title>
            <link>https://medium.com/@sawantarchna/read-data-from-excel-file-apache-poi-in-selenium-18515af2ddcb?source=rss-28ed62a3a7ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/18515af2ddcb</guid>
            <dc:creator><![CDATA[Archana]]></dc:creator>
            <pubDate>Mon, 13 Sep 2021 20:19:26 GMT</pubDate>
            <atom:updated>2021-09-13T20:19:26.950Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction:</h4><ul><li>The Apache POI in Selenium is a widely used API for Selenium Data-Driven Testing.</li><li>POI stands for “Poor Obfuscation Implementation”. Apache POI is an API provided by Apache foundation which is a collection of different Java libraries. This libraries gives the facility to read, write and manipulate different Microsoft files such as excel sheets, power-point, and word files.</li><li>We frequently create a file, open it and update something or delete it on our Computers. The same is the case with Selenium Automation. We need a process to manipulate files with Selenium.</li><li>We are going to learn how can we read and write on an Excel file with the help of the Apache POI.</li></ul><h4>We will see below topics:</h4><ol><li>Why use an Excel file?</li><li>How to add “Apache POI” dependencies/libraries to projects?</li><li>How to Create and Call Excel Read Functions?</li></ol><ul><li>Get Row Count Function</li><li>Get Cell Data String Function</li><li>Get Cell Data Number Function</li></ul><h4>Why use Excel Files in Java Project or Maven Project?</h4><ul><li>In Selenium we can get data from external files like “Excel” and “CSV” so that we do not need to hard code that data within our scripts. It is way to make our scripts independent of data handling.</li><li>External files are used most commonly “Excel” and “CSV”.</li><li>MS Excel is the most commonly used file and this will also enable us to manage our data separately to add updates and all the modifications outside the framework. So whenever we have to make any changes to our data we need not go inside the framework and make any changes.</li><li>We can handle everything from these Excel Files. Also, this will be the first step towards making our data-driven framework.</li></ul><h4>How to add “Apache POI” dependencies in projects?</h4><ul><li>To Read and Write Excel files in Simple Java or Maven Project, Apache provides a very famous library POI . This library is capable enough to read and write both “XLS” and “XLSX” file formats of excel.</li><li>To read “XLS” files, an HSSF implementation is provided by the POI library.</li><li>To read “XLSX”, “XSSF” implementation of the POI library.</li><li>There are two ways for installing an Apache POI jar files depending upon the type of project.</li></ul><ol><li>If the project is a Simple Java Project then you can download jar files from POI download.</li><li>If the project is MAVEN then add dependency in the pom.xml file in the project.</li></ol><h4>Steps to Create Maven Project and also we will see “How to create and call Excel Functions”</h4><p>Open Eclipse and go to “File” — -&gt;click New — -&gt;click “Other”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*hgp1N3xIxPDYnVrlbs2kKA.png" /></figure><p>Then you will see below screen click “Maven” — -&gt;click next — -&gt;click next — -&gt;click next — -&gt;give the details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*D5gAt9P32QdLyOFvud7zUw.png" /></figure><p><strong>Create a new package-</strong></p><p>To create a new package right click on the src/test/java which is below the created project — -&gt;click New — -&gt;click Package — -&gt;give details then you will see the package underneath of project to the left panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*afib9qwi5PAFAMNpdtSqKw.png" /></figure><p><strong>Create a new Class-</strong></p><p>To create a class right click on the created Package — -&gt;click New — -&gt;click Class — -&gt;give details then you will see the created class under the package.</p><p><strong>Add the following dependencies in the pom.xml-</strong></p><p>Here is the link for the Apache POI dependency</p><p><a href="https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml"><strong>https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*sioP4Uk0NKMZISCsmkUryw.jpeg" /></figure><p><strong>Copy above Apache POI dependencies in pom .xml file-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*MOPiMBLpOOWQ059qiREAbA.png" /></figure><p>Maven dependency is added when the pom.xml file is saved after copying the maven dependency. You can check added dependency below the “Maven Dependencies”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*5gKvkyCtg_q6BH7nVt47Kg.png" /></figure><p><strong>How to create Excel file and save data-</strong></p><p>First go to your project — -&gt;right click New — -&gt;go down click “Folder” — -&gt;select Project — -&gt;create new folder — -&gt;select project — -&gt;give folder name — -&gt;click Finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*FNZIeu2KHa7xSBcWQzigWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*2jJT4su4vKMfXjnTiAR0ew.png" /></figure><p><strong>Then inside the folder create Excel File, insert data and save it</strong></p><p>To create Excel file right click on created folder — -&gt;click properties — -&gt;click location — -&gt;click on created folder — -&gt;create Excel file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*1ZEKadcH-Dr-ufa22OtGmA.png" /></figure><p><strong>Next screen will appear after you click the properties, then create excel file.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*dASH5MzSDozatxsR2bOu-Q.png" /></figure><p><strong>In following screen you will see the created Excel file, first refresh the project and then check.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*BweHsmiQIBoosNIPyoTJWg.png" /></figure><p><strong>How to call Excel functions-</strong></p><p><em>Below Excel file used in this Maven project to read data.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*92fpISHkx5MzDan4vJuntA.jpeg" /><figcaption>Excel File</figcaption></figure><p><strong>Here is the logic to read the data from XLSX-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*UELXSc8F9IV6jef1Mnia6Q.jpeg" /></figure><p><em>Continue..</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*D9Y0zXJ6b4Verz92d5WbYQ.jpeg" /></figure><p><em>Continue with output (please ignore WARNING</em>)..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*xv1IQJND9ueP8-NNARUxZw.jpeg" /><figcaption>Output</figcaption></figure><p><strong>Additional information which might be useful to know-</strong></p><p>Apache POI (Poor Obfuscation Implementation File System) is the Java API for Microsoft Documents such as XLX, XLSX, DOC and PPT as well.</p><p><strong><em>HSSF (Horrible Spreadsheet Format)</em></strong></p><p>Read or write an Excel file format — XLS</p><p><strong><em>XSSF (XML Spreadsheet Format)</em></strong></p><p>Read or write an Excel file format — XLSX</p><p><strong>How to create references for Workbook:</strong></p><p>For new Excel format (XLSX)</p><p>XSSFWorkbook workbook = new XSSFWorkbook(“excel file location”)</p><p>For old Excel format (XLS)</p><p>HSSFWorkbook workbook = new HSSFWorkbook(“excel file location”)</p><p><strong>Following is a list of different Java Interfaces and Classes in POI for reading XLS and XLSX files.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*zWikgeO_ghq1X0UxC61gqA.jpeg" /><figcaption>Interfaces and Classes</figcaption></figure><p>Hope this blog was useful!!</p><p>Thank you!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18515af2ddcb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>