<?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 Alexander Griffiths on Medium]]></title>
        <description><![CDATA[Stories by Alexander Griffiths on Medium]]></description>
        <link>https://medium.com/@alex.griffiths?source=rss-825feec35020------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Alexander Griffiths on Medium</title>
            <link>https://medium.com/@alex.griffiths?source=rss-825feec35020------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 19:01:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alex.griffiths/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[A QA beginners guide to Web Element Locator Strategies.]]></title>
            <link>https://medium.com/@alex.griffiths/a-qa-beginners-guide-to-web-element-locator-strategies-8f9c5139136f?source=rss-825feec35020------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f9c5139136f</guid>
            <category><![CDATA[entry-level]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[software-testing]]></category>
            <dc:creator><![CDATA[Alexander Griffiths]]></dc:creator>
            <pubDate>Thu, 11 Jun 2020 17:53:01 GMT</pubDate>
            <atom:updated>2020-06-12T07:45:51.915Z</atom:updated>
            <content:encoded><![CDATA[<h3>A QA Beginners guide to Web Element Locator strategies.</h3><p>I’m not sure if you’ve realised but the software testing industry is changing. The days of manual testers not being required to have a level of technical skills or at least knowledge is slowing ceasing. Especially for roles that are mid-level and above.</p><p>In many environments, we are now expected to be comfortable to engage in technical discussions, be proactive problem solvers and do much more duties that may not necessarily be in the scope of a traditional waterfall Tester. Even if we are not the designated Automation Engineer in an Agile Team by “title”. We may be required to step our testing “foot” into areas that require us to be familiar with software development, networking or databases.</p><p>But don’t be mistaken, this doesn’t mean there isn’t a need for manual testing or its respective job role. However, it’s evident that “Technical Testers” and Test Automation continues to grow. Many of us mid-level professionals with a manual background, had first come to terms with this trend when looking for new opportunities after our first entry role</p><p>It’s ContributeFest here at Intoware and we aim to give back to the community. I aim to discuss some of the basic concepts that you will encounter if you choose to start your test automation journey!</p><h3>1. A Web Page</h3><blockquote>I think I can confidently assume you know the basic principles and purpose of a webpage. But as a QA it’s important to be aware and appreciative of the 3 main perspectives when looking at a webpage. As this will definitely impact what test approach, methodology and tools you will carry out.</blockquote><blockquote>Technical (Does it meet Web architecture &amp; design requirements?)</blockquote><blockquote>Business (Does it meet business requirements?)</blockquote><blockquote>User view (Does it meet the intended users needs? Is it engaging?)</blockquote><p><strong>We’ll be focusing on the Technical!</strong></p><blockquote><strong>Your Average website:</strong></blockquote><blockquote>A modern web page is comprised of 3 main components:</blockquote><blockquote>1. HTML — Hypertext Markup language, used for webpage structuring.</blockquote><blockquote>2. CSS — Cascade Styling Sheets, used for adding custom styles and designs.</blockquote><blockquote>3. JavaScript — a web development language that can utilize both HTML and CSS to create dynamic web content.</blockquote><blockquote><strong>Additional:</strong></blockquote><blockquote>There are also <strong>additional frameworks</strong> available such as Angular, React &amp; Bootstrap that expands the developers capability to create a manageable, smoother and user friendly experience.</blockquote><blockquote>Side note — It would be extremely useful for you as a beginner to play around with all 3 components above, there are various online tutorials to help familiarise yourself.</blockquote><h3>2. Everything on a page is an element</h3><blockquote>Before we go into detail it’s key to understand that we must view everything on a webpage as an object and “element” e.g. Button element.</blockquote><blockquote>There’s a standard format to display an element:</blockquote><blockquote>·<strong> &lt;tagName</strong> attribute=”Value”&gt; Content<strong>&lt;/tagName&gt;</strong></blockquote><blockquote><strong>Few examples:</strong></blockquote><blockquote>Here are some examples of commonly used elements on web pages:</blockquote><blockquote>· &lt;a href= <a href="https://www.websitename.com/">https://www.websitename.com/</a>&gt; Go to website &lt;/&gt;</blockquote><blockquote>· &lt;button type= “button”&gt; Complete &lt;/button&gt;</blockquote><h3>3. Locating elements — How do we find them?</h3><blockquote>Your development team may provide the required elements for your AUT (Application Under Test). But there may be times when you will need to locate them yourself, therefore you need to be able to “look under the hood” of a webpage. Thankfully, we have dedicated tools that allow us to view the hidden content.</blockquote><blockquote><strong>Essential Tool: </strong>Browser Developer Tools</blockquote><blockquote>Usually through f12, right clicking your mouse or found in the browser settings. This tool will give you full access to the required backend of your webpage.</blockquote><p>(Here is where HTML, CSS and also XML knowledge is needed)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5tbAruLBR3gTNeDipPSECA.png" /><figcaption>T</figcaption></figure><blockquote><strong>Useful Tools: </strong>Element Locator (RECOMMENDED)</blockquote><blockquote>You’ll be able to easily generate elements and different locator types.</blockquote><blockquote>Download: <a href="https://chrome.google.com/webstore/detail/element-locator/pldlfgnilfdheajekfphjkjeooignhkc">https://chrome.google.com/webstore/detail/element-locator/pldlfgnilfdheajekfphjkjeooignhkc</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_yBRqPvQkXM4E0SJPqDy4g.png" /><figcaption>This tool will automatically generate what you need by the click of a mouse</figcaption></figure><h3>4.Elements — What do we look for?</h3><blockquote><strong>There are 3 simple methods used when locating elements for coded or codeless UI test automation:</strong></blockquote><blockquote>1. Using an element “ID”</blockquote><blockquote>2. Using element “input name”</blockquote><blockquote>3. Using a “ClassName”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*f--bh6YOD-2ss7uSZVXc0Q.png" /></figure><blockquote><strong>Advanced Methods</strong></blockquote><blockquote>There may be times when you will need to consider a more advanced methods:</blockquote><blockquote>5. Using an Xpath</blockquote><blockquote>6. Using CSS Selectors</blockquote><p>This is when the Element Locator tool is helpful. Once you download and install the add-on to your browser. You’ll be able to quickly identify the tag types, elements, xpaths and the CSS selectors just by clicking objects on the web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIY9TMYG7T0Z1_jnJfjvDQ.png" /></figure><blockquote>Something to consider….</blockquote><blockquote>“It may be helpful to remember a locator will return all elements that match its query so:</blockquote><blockquote>If a locator is too broad, then it could return false positives.</blockquote><blockquote>However, if a locator is too specific, then it could break whenever the DOM (Dynamic object Model) changes and it could also be difficult for others to read.”</blockquote><h4>Reference: Andrew Knight (Test Automation University)</h4><h3>5.Interacting with elements</h3><p>Below I’ll give a simple example of how we can apply these concepts to create a basic automated script that will simulate a user attempting to log-in using invalid credentials.</p><p>1.“Look under the hood”</p><p>Examine the AUT (Application Under Test) using either Google Developer Tools or the Element Locator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5tbAruLBR3gTNeDipPSECA.png" /><figcaption>Team Name and the Continue button are examined via the inspector</figcaption></figure><p>2. Test Automation</p><p>Below is a snippet of Java I coded that uses the Selenium Web driver framework to perform cross-browser tests. The website is launched and the code uses the text-input field’s <strong>ID locator</strong> to send a string value (incorrect credential).</p><p><strong>driver.findElement(<em>By.ID())</em></strong></p><p>The code then references the <strong>ClassName locator </strong>to perform a click event on the “continue” button.</p><p><strong>driver.findElement(By.<em>ClassName())</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9tz7fQJ7uygNMBLfgbqQA.png" /><figcaption>Eclipse IDE: Java</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tz9Z4Jet4OLOvfitCldLWg.png" /><figcaption>An expected error message is generated due to incorrect TeamName value</figcaption></figure><h3>6. Which one is the best one to use?</h3><blockquote>Clearly there are a list of different locator strategies we can choose from to help us interrogate web elements and perform automation.</blockquote><blockquote>But ideally we should choose a locator that is the simpliest way to uniquely identify the desired element.</blockquote><p>Andrew from TAU has pointed out that we should consider “order of preference” approach :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcBsXA36zMw3fzdYJjfeig.png" /></figure><p>Preference 1 to 3 as highlighted earlier are the simplest locators to find and use, but of course, there are limitations. Therefore more advanced and specific approaches may be needed such as CSS selectors or xpaths. CSS selectors allows us to use CSS pattern matching to find elements. While xpaths (there are different types) not only finds the unique elements but also gives room for further interrogation of the web page where even logical operators can be used to query what we see.</p><p>Final words, there are pros and cons to each locator type and I didn’t go through them all. As QA it’s wise to evaluate your project and choose a web locator strategy that not only adds value to your testing. But is also a strategy you’re comfortable with and is adaptable to change.</p><p>References:</p><p>A great tutorial series relating to Web Locators:</p><p><a href="https://testautomationu.applitools.com/web-element-locator-strategies/chapter1.html">Chapter 1 - What&#39;s in a Web Page?</a></p><p>Helpful:</p><p>More detailed information regarding elements and Selenium Webdriver:</p><p><a href="https://www.guru99.com/find-element-selenium.html">Find Element and FindElements in Selenium WebDriver</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f9c5139136f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>