<?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 Abhishek Soni on Medium]]></title>
        <description><![CDATA[Stories by Abhishek Soni on Medium]]></description>
        <link>https://medium.com/@abhishek.soni_89344?source=rss-f7c71956b949------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2DnGd9dmevwO6rrz</url>
            <title>Stories by Abhishek Soni on Medium</title>
            <link>https://medium.com/@abhishek.soni_89344?source=rss-f7c71956b949------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:15:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhishek.soni_89344/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[Cypress tests using the data-cy property]]></title>
            <link>https://medium.com/@abhishek.soni_89344/cypress-tests-using-the-data-cy-property-7594cd61ec93?source=rss-f7c71956b949------2</link>
            <guid isPermaLink="false">https://medium.com/p/7594cd61ec93</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cypress]]></category>
            <dc:creator><![CDATA[Abhishek Soni]]></dc:creator>
            <pubDate>Tue, 30 May 2023 11:08:25 GMT</pubDate>
            <atom:updated>2023-05-30T11:42:21.140Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pMWWqQr1kovkAHGn" /><figcaption>Photo by <a href="https://unsplash.com/es/@florianolv?utm_source=medium&amp;utm_medium=referral">Florian Olivo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Identifying dynamic elements in Cypress tests can be challenging because their attributes, content, or position may change during runtime. However, there are strategies you can employ to overcome this issue.</p><p><strong>Dynamic or changing element identifiers:</strong> If the identifiers of your elements change dynamically or are generated randomly, it can be challenging to consistently locate them in your tests.</p><p><strong>Nested or deeply nested elements:</strong> When dealing with nested or deeply nested elements, it can be difficult to target the specific element you want. Cypress provides various methods to traverse and select elements based on their hierarchy.</p><p><strong>Elements with similar attributes or classes:</strong> If you have multiple elements with similar attributes or classes, it becomes challenging to distinguish between them in your tests.</p><p>Now all these problems can be overcome by adding <strong>data-cy </strong>attributes to an application’s UI elements. It’s a common practice when using Cypress for automation tests. The <strong>data-cy</strong> attribute allows developers to uniquely identify elements for testing purposes, making it easier to write robust and reliable tests.</p><p>Adding data-cy attributes to elements: In your application’s codebase, add <strong>data-cy</strong> attributes to the relevant elements that you want to interact with in your Cypress tests. These attributes should have unique and meaningful values that can be easily referenced in your tests. Here’s a brief explanation of how to add data-cy attributes to your application’s UI elements for Cypress automation tests:</p><p>1. Identify the UI elements: Determine which elements you want to target for testing. These can include buttons, input fields, drop-downs, or any other interactive components.</p><p>2. Add <strong>data-cy</strong> attributes: In your application’s codebase, locate the HTML or JSX tags corresponding to the UI elements you identified. Add a data-cy attribute to each element, providing a descriptive value that represents the element’s purpose in the UI.</p><p>For example, if you have a login button, you can add the data-cy attribute like this:</p><pre>&lt;button data-cy=&quot;login-button&quot;&gt;Login&lt;/button&gt;</pre><p>3. Compile and deploy: After adding the <strong>data-cy</strong> attributes, compile or bundle your application as necessary and deploy it to your testing environment.</p><p>4. Write Cypress tests: In your Cypress test files, you can now use the <strong>data-cy</strong> attribute values to easily select and interact with the UI elements. Cypress provides a cy.get() command to select elements by their <strong>data-cy</strong> attribute value.</p><p>Here’s an example of how you can use the <strong>data-cy</strong> attribute in a Cypress test:</p><pre>it(&#39;should log in successfully&#39;, () =&gt; {<br> cy.visit(&#39;/login&#39;);<br> cy.get(&#39;[data-cy=login-button]&#39;).click();<br> cy.url().should(&#39;include&#39;, &#39;/dashboard&#39;);<br>});</pre><p>In this example, Cypress visits the login page, finds the login button using the <strong>data-cy</strong> attribute value, clicks on it, and then asserts that the URL contains “/dashboard” after successful login.</p><p>By consistently using <strong>data-cy</strong> attributes throughout your application’s UI, you can create a reliable and maintainable test suite with Cypress. The attributes provide a stable and meaningful way to identify and interact with UI elements, even if their underlying implementation changes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7594cd61ec93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run tests with Latest Chrome driver in Docker image]]></title>
            <link>https://medium.com/@abhishek.soni_89344/run-with-latest-chrome-driver-in-docker-image-ca124d8880d0?source=rss-f7c71956b949------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca124d8880d0</guid>
            <category><![CDATA[chome-driver]]></category>
            <dc:creator><![CDATA[Abhishek Soni]]></dc:creator>
            <pubDate>Mon, 28 Nov 2022 09:35:40 GMT</pubDate>
            <atom:updated>2022-11-28T12:33:27.603Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*P3M5wuQ97JRV0cDieHn-Sg.jpeg" /></figure><p>Most of us are aware of how important it is to have the Chrome browser align with the respective Chrome driver version, and it’s a huge challenge to maintain this.</p><p>We can always have a predefined Chrome browser and Chrome driver installed through a Docker image. This is most suitable and reliable when running end to end test jobs. However, in most cases, browsers and drivers are hard-coded and never updated unless there is a need or a failure occurs.</p><p>I recently learned that it is possible to update the latest version of Chrome and the Chrome driver in a Docker image. Later on, it will be published to the respective repository (Jfrog or Docker) and used from there.</p><p>This is one of the hassle-free ways of performing tests on the latest and most stable Chrome version, and you don’t need to manually update it again and again.</p><p>So how does it work?</p><p>Get the latest Chrome browser and install it. Next, you need to figure out what version of the Chrome browser is installed. By pulling this version, we can find out the respective version of the Chrome driver, which needs to be installed accordingly.</p><pre>RUN CHROME_VER=$(google-chrome --version | sed &#39;s/Google Chrome \([0-9]*\).*/\1/g&#39;) &amp;&amp; \<br>    wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VER} -O chrome_version &amp;&amp; \<br>    wget https://chromedriver.storage.googleapis.com/`cat chrome_version`/chromedriver_linux64.zip &amp;&amp; \<br>    unzip chromedriver_linux64.zip &amp;&amp; \<br>    mv chromedriver /usr/local/bin/ &amp;&amp; \<br>    DRIVER_VER=$(chromedriver --version | sed &#39;s/ChromeDriver \([0-9]*\).*/\1/g&#39;) &amp;&amp; \<br>    echo &quot;chrome version: $BROWSER_MAJOR&quot; &amp;&amp; \<br>    echo &quot;chromedriver version: $DRIVER_VER&quot; &amp;&amp; \<br>    if [ $CHROME_VER != $DRIVER_VER ]; then echo &quot;VERSION MISMATCH&quot;; exit 1; fi</pre><p>This will also verify the installed versions of both, or else the process will abort in other case.</p><p><em>Conclusion<br></em>Yes, it appears to be extremely brief and basic, but when used in the process, it is highly successful. Although this will not help if tests run need to be performed on a specific version.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca124d8880d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>