<?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 Santhosh on Medium]]></title>
        <description><![CDATA[Stories by Santhosh on Medium]]></description>
        <link>https://medium.com/@santhoshshetty58?source=rss-be54146a5b9f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*wJtBEcPVMS1SHeP-</url>
            <title>Stories by Santhosh on Medium</title>
            <link>https://medium.com/@santhoshshetty58?source=rss-be54146a5b9f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:30:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@santhoshshetty58/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[Gitub Copilot: Revolutionizing Coding with AI Assistance]]></title>
            <link>https://medium.com/@santhoshshetty58/gitub-copilot-revolutionizing-coding-with-ai-assistance-bef2b8b4a291?source=rss-be54146a5b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bef2b8b4a291</guid>
            <category><![CDATA[coding-assistant]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <dc:creator><![CDATA[Santhosh]]></dc:creator>
            <pubDate>Thu, 16 May 2024 21:24:07 GMT</pubDate>
            <atom:updated>2024-05-16T21:24:07.196Z</atom:updated>
            <content:encoded><![CDATA[<p>Looking back a decade, the life of a software engineer has undergone significant changes in resource availability, knowledge accessibility, and support systems. In the past, aspiring software developers faced numerous challenges, from grasping concepts to implementation, debugging, issue-solving, documentation, and delivery. Each phase presented hurdles, diminishing individual efficiency and rendering routine tasks monotonous.</p><p>With the boom of social platforms in the tech space, where people collaborate with an exchange of knowledge, helping each other solve issues from experiences, most software engineers gained confidence in learning and developing a system with any of the new technologies.</p><blockquote>Now we are in the golden era of AI and ML, where all the above solutions are at our fingertips, where the tools can train us, support us in writing the code, that can debug, fix the issues, and do all the mundane tasks that consume a lot of time.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*piRs6PeOeABbdyQLhMSBmw.png" /><figcaption>source — github.blog</figcaption></figure><p>Since the introduction of ChatGPT, Generative AI has gained immense popularity in the industry, with widespread adoption of AI technology becoming an integral part of the lives of anyone working on computers. For software engineers, the Gen AI system is now accessible through GitHub Copilot, seamlessly integrated with all popular editors. Github copilot is a code completion tool developed by GitHub, Open AI, and Microsoft that assists users of VS code, and JetBrains integrated development environments by autocompleting code</p><blockquote>Github Copilot is an AI coding assistant that helps you write code faster with less effort, allowing you to focus more energy on problem-solving and collaboration</blockquote><blockquote>Github copilot is trained on all languages that appear in public repositories. For each language, the quality of suggestions you may receive depends on the volume and diversity of training data for that language.</blockquote><p>There is a lot of documentation available on the Copilot <a href="https://github.com/features/copilot">page</a>, how it was trained, and what it can do — As part of this blog I want to highlight to the ones who are new and exploring this, how it’s helpful at least for a programmer of me in web services development or the automation of tests.</p><p>Let’s take a small example, of how it has been effective by taking a simple task of <strong><em>automating filling in address details</em></strong>, let’s take Typescript as the programming language, Cypress as the automation tool, and Visual Code Studio as the editor and GitHub copilot installed on it.</p><ol><li>The first step is to identify the elements of the screen you want to automate. Now, add the locators in the script, and observe as you keep adding them the copilot pitches in and gives you some suggestions be it at the variables declaration or syntax completion as a ghost text. It’s up to you to use them if you find them relevant by clicking on the tab button, else you can ignore them.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azJHivUGBjSfFV0ZdXGDBg.png" /></figure><p>2. Once the locators are identified, say the following actions to be performed— enter first name, house number, postal code, and city, and submit. <br>Instead of directly writing Cypress commands to perform actions, we’ll add comments specifying what actions need to be performed, like ‘enter first name value’ as shown in the screenshot below. Copilot understands the context even while adding these comments and checks for defined variables, helping in comment composition. After writing the comments, pressing enter generates the code snippet below each comment line, and completing all the necessary code with just a few tab clicks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w0FjE8VtiyvdwTvbDKSKtA.png" /></figure><p>3. Now, say you want to enter the postal code with a random value. So, let’s ask the copilot to create a utility method to generate a random postal code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gAJkqmtdUCofnRv0I5JSAA.png" /></figure><p>4. Now, in the respective action remove the hardcoded value and give a tab, and the copilot suggests completing with the new method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CTKVqvBsc1iJTleHeb-Ssg.png" /></figure><p>5. Now, let’s make use of it much more effectively, if you are in doubt about whether the utility method will work or not, then select that method and do a contextual click ask, copilot to write the tests, or write a comment saying it to write a unit test for it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QEzN1JAijEIoHBCY_BfTsg.png" /></figure><p>6. From the same contextual menu, you can ask it to generate the docs and avoid all the mundane tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YQnyEJIUepcbTwi8u_qa5Q.png" /></figure><p>7. Say, you have run into an issue, and see a red alert in the code, do the mouse hover and ask the copilot to either fix the issue or explain the issue. Explain the issue will open up a chat window on the left panel and it explains the issue and points out all the resources Selection of the ’ Fix the issue’ will fix the problem and shows up a button Accept and Discard for you to perceive it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uup6ljoDlvBgvJeCA0MNqA.png" /></figure><p>8. Within the chat window, you have the option to ask various questions, and Copilot will explain them using available resources. If you’re unsure about existing code, simply select it and ask Copilot to explain, and it will provide a detailed explanation with all available resources. You can then further inquire and refine your queries to get the necessary resolutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*N5qVGZJoLoYIplzPA1GOhw.png" /></figure><p>9. When debugging, if you want to check something in the repository, simply tag <a href="http://twitter.com/workspace">@workspace</a> in the chat window and query. Copilot will scan through your repository’s resources and provide the locations where it’s employed, helping you efficiently locate the instance you’re looking for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*je-bq24O0OQ_XX0WGnSVlQ.png" /></figure><p>10. If you want to control Visual Studio Code components or settings, use the annotation <a href="http://twitter.com/vscode">@vscode</a> in the chat. Copilot will provide you with the answer and a button directing you to the respective option, allowing you to efficiently manage your Visual Studio Code environment.</p><p>11. As we are automating the scenario of filling a form, if you’re unsure about intercepting a request, simply add a comment with the letter “q:” and Copilot will explain it, assisting you in understanding the concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcciUZIouOW5A2oQOGEfUw.png" /></figure><p>12. If you want to have an interactive session, we can go to the chat window on the left panel, and if you want to just take an answer, press ctrl+shift+i and it gives you a palette for asking a question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2tl5XQuWkj_bmTM1qNd2Yg.png" /></figure><p>13. Now, all the development is completed, and you want to commit, and again to avoid the mundane task of drafting the comments, the copilot intelligently understands the changes from the commit files and generates pull request comments.</p><p>14. We will conclude this blog with a cool feature: Copilot’s ability to comprehend other languages and transpile them into English syntax. Below is an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*xmgEWxC6orOK0eZN3Nao1Q.png" /></figure><p>So, from the above demonstration, in every phase, the copilot has transformed the experience and made the most efficient resources for us.</p><p><strong>Use AI code assistants wisely:<br></strong>There are differences in opinions about the quality of code these tools generate, but always remember they are just the trained system and the onus lies on us to how to make the best use of them.</p><p>Use these AI assistants more cautiously, and don’t presume this to be a solution that builds everything for you. As the name suggests it is meant to be an assistant, and it&#39;s not every time to produce the correct or the most secure code.<br>It&#39;s tempting to make co-pilot do a lot of code, it is fantastic for code suggestions, but review everything it generates and make a wise decision.<br>Let it be the copilot guiding you in the direction and you be the captain of the flying plane</p><blockquote>Make sure, you are adhered to NDA (non-disclosure agreement) rules from your company or client and do not put any secrets, or confidential information to the copilot. Always seek permission before using it. And for your personal space to learn or implement, there are many such tools available in the market. the open-source and popular Amazon whisperer. Try it out and be an efficient programmer.</blockquote><p>For an easy understanding, I took a basic example, but we can achieve a lot using these tools. Please feel free to share your thoughts and happy learning.</p><blockquote><strong>Latest update — </strong><br>GitHub Copilot has launched a ground breaking platform named Workspace. It offers end-to-end implementation of a feature, from understanding requirements to planning changes and implementing them.</blockquote><blockquote>Within Copilot Workspace, developers can now brainstorm, plan, build, test, and run code in natural language. It functions as a complete Software Engineer.</blockquote><p><strong>References:<br></strong><a href="https://github.com/features/copilot">https://github.com/features/copilot</a><br><a href="https://docs.github.com/en/copilot/using-github-copilot/getting-started-with-github-copilot">https://docs.github.com/en/copilot/using-github-copilot/getting-started-with-github-copilot</a><br><a href="https://githubnext.com/projects/copilot-workspace/">https://githubnext.com/projects/copilot-workspace/</a><br><a href="https://aws.amazon.com/codewhisperer/">https://aws.amazon.com/codewhisperer/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bef2b8b4a291" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebDriver BiDi — Future of Browser Automation]]></title>
            <link>https://medium.com/@santhoshshetty58/webdriver-bidi-the-game-changer-603bb2d51831?source=rss-be54146a5b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/603bb2d51831</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[webdriver]]></category>
            <category><![CDATA[w3c]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[bidi]]></category>
            <dc:creator><![CDATA[Santhosh]]></dc:creator>
            <pubDate>Sat, 30 Mar 2024 13:02:09 GMT</pubDate>
            <atom:updated>2024-03-30T13:13:51.211Z</atom:updated>
            <content:encoded><![CDATA[<h3>WebDriver BiDi — Future of Browser Automation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*Z0260-9duMrRRtNYepkTBQ.png" /></figure><p>In this blog article, I present an in-depth analysis of how WebDriver BiDi is positioned to revolutionize the automation landscape. Let’s explore how automation tools equipped with WebDriver BiDi will benefit, examine the inception of the WebDriver protocol, compare it with other automation implementations, discuss the differences between them, and explain why BiDi is the need of the hour and a game-changer for Selenium. Let’s dive in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybLL6cxckj7CflPeNnxnSw.png" /><figcaption>Image Source — <a href="https://developer.chrome.com/blog/webdriver-bidi">https://developer.chrome.com/blog/webdriver-bidi</a></figcaption></figure><p>As most of us know, Selenium WebDriver is the popular automation framework for Web Automation. It has been widely used for a decade due to reasons such as W3C standard compliance, open-source nature, multi-language and multi-OS support, extensive browser support, and real-time emulation capabilities.<br>While Selenium WebDriver may lack some promising features found in tools like Cypress and Playwright, such as built-in features, a comprehensive test runner, and faster execution speed, it still holds significant potential for growth. Despite facing some competition and losing traction among users, Selenium continues to move in a promising direction, especially with the development of the WebDriver BiDi protocol.</p><p>Let’s deep dive and understand the basics of WebDriver right from scratch, W3C. We will cover the evolution of WebDriver to its current state.</p><p><strong>Inception of WebDriver protocol:<br></strong>The web became a reality in the 1990s, and in the late 2000s, Jason Huggins at Thoughtworks introduced the concept of automation testing and developed a tool named Selenium. Later, it was upgraded to Selenium RC, and then the Selenium team transitioned to Google, continuing their work on Selenium. Meanwhile, another developer, Simon Stewart, conceived the idea of WebDriver, a powerful API for web automation. After discussing this concept with Huggins and the Google team, they found it to be more compelling and efficient. As a result, Selenium and WebDriver were merged to form WebDriver Classic. Thus, with collaboration from automation teams and browser vendors, the WebDriver protocol was developed and released as Selenium WebDriver in 2011. In 2018, due to its popularity, WebDriver was adopted as the standard and became the W3C WebDriver protocol, now recognized as the industry standard.</p><p><strong>Protocol:</strong> It represents a contractual agreement between two entities that communicate. This agreement mandates the format in which they exchange information and the shared common semantics</p><p><strong>Wrappers built on top of Selenium to support diverse automation capabilities:</strong> <br>Appium was introduced in 2012 to support mobile automation built over Selenium, leveraging the WebDriver protocol.</p><p><strong>Automation tools based on NodeJS:</strong> <br>While these advancements were happening, other tools were evolved in the market, with Node JS introduced in 2009, many people looked for projects based on Node JS, and the tools came out like Webdriver IO (again it uses the WebDriver protocol under the hood), and Cypress, Test Cafe, etc. Here, Cypress and similar protocols don’t use the WebDriver protocol under the hood, but it injects JavaScript within the browser and runs the tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLGyfdVQQxZOt8a-ggpLQA.png" /><figcaption>Image Source — <a href="https://developer.chrome.com/blog/webdriver-bidi">https://developer.chrome.com/blog/webdriver-bidi</a></figcaption></figure><blockquote>Now we have two sets of automation implementations here: one is based on the WebDriver protocol and the other is running the tests within the browser. These two can be categorized as <strong>High-level and Low-level implementations:</strong></blockquote><p><strong>High-level:</strong> Cypress-based implementations fall under this category, where the automation tool uses Web API and injects the JavaScript within the browser to run the tests. Because of this, the automation tool is bound by the sandbox created by the JS code. <br><strong>Pros: </strong><br>1) Execution speed is fast and more control over the browser features, etc. <br><strong>Cons: </strong><br>1) They could not be considered as user interactions where mostly JS-based commands are used to perform the operations where the actions are made manipulating the DOM. <br>2) <strong>Security issues</strong> - Browsers are very picky and cautious. The browser does not trust the events coming from a script. Hence if you want to perform complex functions like opening a new tab and window and frame, the browser will not let you do that because it doesn’t trust you enough, and won’t let the control move out of the sandbox created by the JS code.</p><p><strong>Low-level:</strong> This can be categorized into subsets — one is using the <strong><em>WebDriver classic protocol (Selenium, WebdriverIO, Appium, Nightwatch, etc.), and the other is using the CDP (Puppeteer)</em></strong>. Let’s discuss in detail about how these subsets work internally:</p><p><strong>WebDriver classic:</strong> <br>In the WebDriver classic system, a client represents the automation framework (e.g., Selenium WebDriver, Webdriver IO) and browser drivers developed by vendors. These drivers communicate with browser binaries via HTTP JSON protocol to execute actions like ‘click’, ‘send keys’, ‘hover’, etc. Each action is an API call to the browser binary, which then performs the action and responds to the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qIeM4DIYTgF0RUlUj6PR5Q.png" /><figcaption>Image Source — <a href="https://developer.chrome.com/blog/webdriver-bidi">https://developer.chrome.com/blog/webdriver-bidi</a></figcaption></figure><p><strong>Pros: </strong><br>1) Automation is performed by sending the remote commands outside the browser. The remote commands add events directly to the event loop of the browser<br>2) Since all the browsers accepted it as standard web driver protocol and after it became W3C standard, there is no issue with compatibility and this WebDriver protocol has multi-browser support. <br>3) It emulates real user actions by asking the browser to run the commands.<br><strong>Cons:</strong><br>1) <strong>Speed</strong> — This slowdown is due to the stateless nature of HTTP, requiring a new connection for each command execution. Consequently, every action necessitates establishing a new connection, impacting speed. For instance, if a prerequisite on a webpage isn’t fulfilled, commands must wait until resolved, like waiting for an element to become visible, resulting in multiple command transmissions until fulfillment.<br>2) Not Event driven<br>3) Bi-directional communication is not possible<br>4) No access to network features</p><p><strong>CDP (Chrome DevTools Protocol): </strong><br>When building an application, developers require insights into its functioning, such as console logs and network requests. Chrome developed a tool called DevTools for debugging. The Chrome DevTools Protocol (CDP), primarily for developers, aids debugging. CDP enables access to browser DevTools. Google introduced Puppeteer, an automation tool utilizing CDP to interact with browsers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jKc3OaX6OSHvnkY3fWP_iA.png" /><figcaption>Image Source — <a href="https://developer.chrome.com/blog/webdriver-bidi">https://developer.chrome.com/blog/webdriver-bidi</a></figcaption></figure><p><strong>Pros: </strong><br>1) Since CDP can do low-level control which means it can access everything over the application like-<br>a) Monitor console messages<br>b) Intercept network requests<br>c) Simulate device mode<br>d) Simulate geolocation etc.,<br>2) <strong>Web Socket communication:</strong> CDP works on WebSocket communication and it doesn’t require any driver. CDP commands can directly talk to the browser. WebSocket is <strong>2-way communication</strong> and hence the speed is fast and we can configure listeners and continue our execution, where the browser will return the response in the execution when the condition of the listeners is satisfied. Hence it is <strong>event-driven</strong>.<br><strong>Cons: </strong><br>1) Supports only Chromium-based browsers<br>2) Unstable API — as Chrome keeps releasing new versions the CDP APIs have to be adopted, hence we have to keep adopting the automation scripts according to the new APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cdlSVpYmM5yKmYDacTitFA.png" /><figcaption>Top — High-level approach, Bottom — Low-level approach *Image Source — <a href="https://developer.chrome.com/blog/webdriver-bidi">https://developer.chrome.com/blog/webdriver-bidi</a></figcaption></figure><blockquote>“So, now we have discussed three approaches: one is based on JavaScript, where JavaScript is injected, but we do not want to pursue that direction as it’s entirely high-level and represents a different model altogether. Now, within low-level implementations, we have certain advantages and disadvantages with each of the tools. So, what if there exists a solution where the best of both worlds are brought together? For example, Real User Emulation, W3C standard compliance, Multi-browser support, Event-Driven architecture, and Bi-Directional communication. That’s where the solution comes in the form of <strong>WebDriver BiDi.</strong>”</blockquote><p><strong>WebDriver BiDi </strong>— enables real-time communication between WebDriver clients and web browsers using WebSockets. This bidirectional communication allows for more efficient control and monitoring of browser activities, enabling advanced features and better performance.<br>Work on WebDriver BiDi was started in 2020 by the W3C Browser Testing and Tools working group This work is a collaboration: Webdriver BiDi working group comprises browser vendors (chrome, firefox, safari), open-source browser automation projects (selenium, webdriverIO), and companies offering browser automation solutions (Browser Stack, Sauce labs). All these stakeholders work together in harmony to bring a simple and unified solution for the testers that is easy to implement<br><a href="https://w3c.github.io/webdriver-bidi/">https://w3c.github.io/webdriver-bidi/</a><br><a href="https://github.com/w3c/webdriver-bidi">https://github.com/w3c/webdriver-bidi</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rvlaAe-MvrxXJC5Ry8FwFg.png" /><figcaption>Image Source — <a href="https://developer.chrome.com/blog/webdriver-bidi">https://developer.chrome.com/blog/webdriver-bidi</a></figcaption></figure><blockquote>What does it take to implement the new protocol —<br><strong> Specification &gt;&gt;&gt; Verification &gt;&gt; Implementation</strong></blockquote><p><strong>Specification</strong> — The W3C has a dedicated webpage for Webdriver BiDi, providing definitions for modules, events, commands, and errors. Anyone or any tool interested in implementing WebDriver BiDi can participate and contribute to the specifications. Detailed specification information can be found here <br><a href="https://w3c.github.io/webdriver-bidi/">https://w3c.github.io/webdriver-bidi/</a><br><strong>Verification</strong> — We have a GitHub repository containing web platform tests written in Python. Any tool aiming to implement BiDi must pass these tests as the source-of-truth for all the implementations.<br><a href="https://github.com/web-platform-tests/wpt/tree/master/webdriver/tests/bidi">https://github.com/web-platform tests/wpt/tree/master/webdriver/tests/bidi</a><br><strong>Implementation — </strong>Browsers implement the protocols according to the spec and pass the verification tests. Challenges<br><a href="https://wpt.fyi/results/webdriver/tests/bidi">https://wpt.fyi/results/webdriver/tests/bidi</a></p><p><strong>WebDriver BiDi Initial Support:<br></strong>Webdriver classic to Webdriver BiDi initial support is already given in automation tools like Selenium via CDP (from Selenium 4), and now the adoption to BiDi is in progress<br>1) Capture console logs<br>2) Network Interception — Mocked response — <strong>In-Progress</strong><br>3) Accessibility — Talks have already started for implementing accessibility in BiDi etc., <br><br><strong><em>If you observe the release notes of Selenium, you’ll notice that the adoption of WebDriver BiDi is in progress in the backend, many thanks to the Selenium team for their efforts.</em></strong></p><p>Here are the sample release notes of the release (the latest as the blog is prepared) where you can find the bidi changes incorporated in that version — <a href="https://www.selenium.dev/blog/2024/selenium-4-19-released/">https://www.selenium.dev/blog/2024/selenium-4-19-released/</a></p><p><strong>How it changes for the end user:</strong> WebDriver BiDi interoperates with WebDriver Classic, that is existing commands in “Classic” will use BiDi under the hood. example — click, navigate, etc., <br><em>*Remember, there wouldn’t be any drastic changes for the user in the usage of existing features.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeVhmQ8wUCN6xwHa3lFIzQ.png" /><figcaption>BiDi — Sample script for tracing the JS Errors from the console</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6-19l6w07pIUDHcyJHnMBQ.png" /><figcaption>BiDi — Sample script for ‘Add Network Intercept’</figcaption></figure><p>You can refer to sample programs for accessing dev tools using BiDi at the following location — <a href="https://github.com/santhoshshetty/CodePlayground/tree/main/src/test/java/demo/webdriver/bidi">https://github.com/santhoshshetty/CodePlayground/tree/main/src/test/java/demo/webdriver/bidi</a><br>For detailed BiDi tests refer to the Selenium GitHub repo posted in the references section</p><blockquote><strong>Conclusion: In conclusion, WebDriver BiDi stands out as a game-changer for automation, leveraging the benefits of Bi-Directional Communication, Event-Driven architecture, Multi-browser support, access to low-level controls such as Console and Network, and adherence to the W3C standard. Let’s begin adopting these new features as they’re released and witness the benefits firsthand.</strong></blockquote><p>Thank you for reading my blog. If you found it valuable, please give it a thumbs up. Stay tuned for another interesting blog on a similar topic, focusing on how the architecture of the latest frameworks like Cypress and Playwright is optimizing and enhancing automation efficiency.</p><p>References:<br><a href="https://developer.chrome.com/blog/webdriver-bidi">https://developer.chrome.com/blog/webdriver-bidi</a><br><a href="https://www.selenium.dev/documentation/webdriver/bidirectional/webdriver_bidi/">https://www.selenium.dev/documentation/webdriver/bidirectional/webdriver_bidi/</a><br><a href="https://www.youtube.com/watch?v=6oXic6dcn9w">https://www.youtube.com/watch?v=6oXic6dcn9w</a><br><a href="https://www.selenium.dev/documentation/webdriver/bidirectional/">https://www.selenium.dev/documentation/webdriver/bidirectional/</a><br><a href="https://github.com/SeleniumHQ/seleniumhq.github.io/tree/trunk/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi">https://github.com/SeleniumHQ/seleniumhq.github.io/tree/trunk/examples/java/src/test/java/dev/selenium/bidirectional/webdriver_bidi</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=603bb2d51831" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contract Testing using Pact]]></title>
            <link>https://medium.com/@santhoshshetty58/contract-testing-using-pact-a0caddc08bed?source=rss-be54146a5b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0caddc08bed</guid>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[contract-testing]]></category>
            <category><![CDATA[microservices-testing]]></category>
            <category><![CDATA[pact]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Santhosh]]></dc:creator>
            <pubDate>Fri, 29 Dec 2023 23:00:31 GMT</pubDate>
            <atom:updated>2023-12-29T23:01:57.578Z</atom:updated>
            <content:encoded><![CDATA[<p>We have transitioned from a time when deployments occurred once every few days to a scenario where deployments take place every few seconds within an application, whether in a higher or lower environment. As applications transform into microservices, enterprise applications now comprise tens or hundreds of microservice applications. The changes within each microservice are very frequent, and with interdependencies among services, the impact of changes in one service can affect others. Identifying these impacts after deployment can be costly. To address this challenge, we need to detect issues during the code development phase. <br>So let’s see how this issue can be handled, but before doing so, let’s take a step back to revisit some basics and understand the problem and its solution.</p><p><strong>Monolithic vs Microservice:<br></strong>In the monolithic architecture, when the front end interacts with the back end, there is one single instance responsible for the application&#39;s business functionality.<br><strong>Example</strong> — The user interface communicates with a server repository (say — User Profile, Orders, Products, Payments, Notifications) and a database. In a monolithic architecture, all functionalities exist in one code base with projects having APIs created to access data and talk to a single database. For simple applications, we can continue with the monolith architecture.</p><p><strong>Challenges in the Monolith approach:<br>- </strong>If the server or instance goes down, you cannot access the website, as everything is on one server.<br>- While there may be limited load, on special days with significant traffic, scaling up resources becomes necessary. However, the problem is that multiple resources are shared by all features, and required ones may not be available. <br>- For any error in business functionality, redeploying the entire system is necessary, leading to a server outage for errors like product search.<br>- The monolith has a massive code base making it difficult to maintain.<br>- Everything is tightly coupled, and upgrading some stack or a feature to another technology requires updating the entire system.</p><p><strong>Benefits of adopting Microservices:<br></strong>The above-discussed problems can be resolved by adopting microservices. Identify the application’s business functionalities, and spin up a microservice for each, with a separate database for each functionality. For instance,<br>- Upgrading Orders to MongoDB for efficiency won’t impact other services. <br>- If there’s an issue in payments, only the payments scenario goes down when redeployed, not affecting other services.<br>- Orders tech stack can be handled in Java, Payments in JavaScript, and Products in Python or Ruby.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xfn7SjY7g8JJTRY0sBoeVQ.png" /><figcaption>Image source — Developer.com</figcaption></figure><p><strong>How Microservices Communicate:<br></strong>Microservices communicate with each other through REST API calls. For example, from the User Profile, calling the get Orders method retrieves all orders by sending the profile ID. <strong>Intercommunication between microservices is made through REST API calls</strong>. <br>On a monolith, the front end or user interface talks to only one system. In microservices, the front end can talk to orders, and in turn, orders talk to payments and return responses.</p><p><strong>Microservices testing:</strong><br>From a testing perspective, we can write some API integration tests, run them against the test environment, and then verify if we are receiving the correct data from the provider. However, shifting our focus to microservices, where large software projects are broken down into smaller, independently developed modules or components by different teams, introduces various challenges to testing.</p><p><strong>Challenges in testing the interdependent microservices :<br>- </strong>The challenge arises when attempting to test all the different microservices in a dedicated testing environment. <br>- Different teams can deploy their changes to different services simultaneously, resulting in constantly changing data. <br>- Some services might be down due to environmental issues. Relying solely on testing the integration points via real services becomes cumbersome.</p><p>Deploying small, independent services has its benefits, but on the flip side, integration testing becomes complex as the number of integration points increases. Imagine dealing with hundreds of thousands of services communicating with each other, similar to what companies like Amazon or Netflix have. How can you ensure that every change you make doesn’t cause issues with other services?</p><p><strong>Mock Services — Testing in isolation without invoking the real service:<br></strong>Isolated tests offer significant value. They provide a fast feedback loop to check if different inputs yield the expected outputs. For instance, consider a consumer making a GET request to users, and there’s also a mock provider predefined with a response status code of 200 and an object with a name and value. Simultaneously, the provider has isolated tests by simulating what the consumer is expecting.</p><p><strong>Challenges running with mocked services:</strong><br>- It doesn’t give us confidence that the mock provider accurately represents the real provider. <br>- The same applies to the consumer. Additionally, it doesn’t prevent broken changes from being deployed in a dedicated environment, as the provider or the consumer can deploy broken changes to production, especially if they are on different pipelines and don’t regularly trigger each other’s tests.</p><p><strong>Here we will summarize the testing types performed for microservices testing and its challenges</strong></p><p><strong>Unit Testing </strong>— Test with mock services/data<br>- Lacks confidence for release.<br>- Mock providers may not accurately represent the real provider and the same holds for consumers.<br>- Broken changes can be deployed, especially if on a different pipeline.</p><p><strong>Integration Testing</strong> - Tests actual endpoints<br>- When a consumer makes a request, instead of communicating with a mock provider, it talks to the real provider. <br>- However, having too many of these tests becomes complex in microservices. <br>- They are slow and brittle, particularly when dealing with frequent data changes. <br>- Moreover, they require dedicated environments where services integrate, leading to extensive test maintenance. <br>- Additionally, they don’t prevent the deployment of broken changes.</p><blockquote>To address these challenges, we need an intermediate step between unit testing and integration testing. This step goes beyond testing with mocks in isolation but involves less interaction with the real systems. It focuses on verifying that one service meets the expectations of another. This middle ground involves testing with mocks, yet the system understands what the other system expects. This is where contract testing comes into play.</blockquote><blockquote><strong>Contract Testing:</strong><br>Contract testing is a technique for testing an integration point by checking each application in isolation to ensure the messages it sends or receives conform to a shared understanding that is documented in a “contract”.</blockquote><p>Let’s understand the importance of Contract testing through a simple within a team discussing an issue in a retrospective meeting.</p><blockquote>Q: Why didn’t unit test cases catch the failure?<br>A: We mocked the response of the external microservice.</blockquote><blockquote>Q: Why did you mock the external dependency?<br>A: Unit tests should be conducted in an isolated manner with stubbing/mocking dependencies.</blockquote><blockquote>Q: Why did you have the wrong mock response?<br>A: Below is the contract we agreed upon while consuming the response from the All Courses microservice. So, we are using this mocked contract to test our code.</blockquote><blockquote>Q: What was the reason for the exact failure?<br>A: We are parsing JSON and grabbing the field to sum up all the courses. The provider microservice has changed the contract and is now sending the field name as “pricing.” Our code base cannot identify the “pricing” field, and it failed to parse the JSON. Unit tests did not catch this because we are using a mock response that has the “price” field. According to that mock response, the test passed. However, when QA tested it with the real service in their end-to-end or integration test, it broke.</blockquote><blockquote>Q: Why did you not update your change to the consumer?<br>A: Many teams are consuming this service, and we are not sure which team is using what field. So, we just updated our documentation for the change we made, and they must check our documentation every time.</blockquote><blockquote>Q: How one can monitor these contract changes every time, if the provider doesn’t reach us for the exact changes made?<br>A: Why worry? A team will however catch the issue on their e2E testing. and we can fix it</blockquote><blockquote>Q: Is that not too late? we are agile and contract change issues should be identified in the early life cycle. and we are dependent on the total<br>7 providers in consuming the data. How we can keep track of all these schema/contract changes?<br>A: Is there any tool, where can define our expectations on what fields in the JSON contract we are using<br>so that provider-side test cases will break where they try to make some changes that are in contract with other systems<br>That way, they will know and drop a heads-up to us on changes</blockquote><h3>WELCOME to PACT:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*gC_4zy5LI9aJrXjpbejtCw.png" /><figcaption>image source — pactflow.io</figcaption></figure><ul><li>Pact provides an RSpec DSL for service consumers to define the HTTP requests they will make to a service provider and the HTTP responses they expect back.</li><li>These expectations are used in the consumer specs to provide a mock service provider.</li><li>The interactions are recorded and played back in the service provider specs to ensure the service provider does provide the response the consumer expects.</li><li>The Pact specification is supported in various programming languages such as Java, Ruby, Python, Go, C++, etc. Specifically in Java, it can be utilized in conjunction with JUnit 5.</li></ul><blockquote>This allows testing of both sides of an integration point using fast unit tests.</blockquote><ul><li>Two services, a consumer and a provider, are interacting via a REST API, with the expectation of receiving a specific status code and response.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*qz7JYCDgpCvBz90S-_PywQ.gif" /><figcaption>image source — Pact docs</figcaption></figure><ul><li>Use Pact as a mock provider to avoid directly interacting with the real service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*PYda8oOV_1ajTG3-bnGzTw.gif" /><figcaption>image source — Pact docs</figcaption></figure><ul><li>Write tests on the consumer side, mocking the expected data from the provider. Cover all scenarios, specifying the expected status and response values.</li><li>Pact automatically generates a contract file (JSON) with all the interactions from the test runs. and uploads it to the PACT Broker.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*VF57Anq8GqfPrZNKuqH4IA.gif" /><figcaption>image source — Pact docs</figcaption></figure><ul><li>The provider consumes this contract file from the Pact Broker. All interactions are executed on the actual provider service, and the result is compared with the expected outcome.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*wvqcXg7YCm8O-tqpTqYg8Q.gif" /><figcaption>image source — Pact docs</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LFB-YfrYr8ZwgFbFHBq3PA.gif" /><figcaption>image source — Pact docs</figcaption></figure><ul><li>This approach ensures that any changes made by the provider to their API are immediately flagged during development. Issues are highlighted, indicating that local changes may break the consumer, as the contract test has failed.</li></ul><p><strong>Case study:</strong><br>Let’s create a simple contract test. We have a library service offering book resources and a courses service providing online course resources. When the front end calls the library service, it, in turn, calls the courses service. The library service consolidates the responses, summing up resource prices, and sends them back to the front end. Here, the library service is the consumer, and the courses service is the provider. They have a contract or integration point; for example, the provider (courses service) should respond with the price as an integer and the category name as a string in the response JSON.</p><p><strong>Pre-requisite:</strong><br>Download the Spring Boot projects (consumer, producer) from the URLs mentioned in the references section.<br>Add consumer and provider pact dependencies and the pact broker configuration in the build file<br>PACT JVM Junit 5 for Consumer — <a href="https://mvnrepository.com/artifact/au.com.dius.pact.consumer/junit5">dependency</a><br>PACT JVM Junit 5 for producer — <a href="https://mvnrepository.com/artifact/au.com.dius.pact.provider/junit5">dependency</a><br>Pact Broker configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GXzAmSCw571Vve8lIMWdyQ.png" /></figure><p>Now, let’s write the consumer test to create a contract JSON file.</p><p><strong>Consumer Test:<br></strong>1.<strong> </strong>Add Pact configurations at the Consumer class<br>- <strong>@SpringBootTest</strong> — It is part of the Spring Boot Testing framework indicating the class should be treated as a Spring Boot Test<br>- <strong>@ExtendWith(PactConsumerTestExt.class) </strong>— ExtendWith is JUnit 5 annotation that is used to register extensions in JUnit tests. It facilitates the Pact features to the test class file to perform the contract testing<br>- <strong>@PactTestFor</strong> annotation is used to specify the provider against which the interactions defined in the test should be verified. The name below “CoursesCatalogue” has to be mentioned the same as Provider and this binds the Provider and Consumer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*pxpJayhKeVNq1c1JSGW2IA.png" /></figure><p>2. Prepare a mock response for what the course service is supposed to respond with.<br>- <strong>@Pact</strong> annotation is used to mark the method that generates a Pact between the consumer and provider<br>- <strong>PactDslWithProvider</strong> object is automatically injected by Pact and it provides a fluent DSL for constructing a Pact between the consumer and provider</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ENQjDdWOF3KzcEaBEUkjcA.png" /></figure><p>3. Write the test, making a GET request with the resource, and write assertions for the status code and response.<br>- <strong>@PactTestFor</strong> — It indicates that this test is associated with the interactions defined in the above interactions (or Mock Response)<br>- <strong>MockServer</strong> object is automatically injected by Pact and it provides the URL where the mock server is running<br>- <strong>setBaseURL</strong> — Override the host URL so that the API request is redirected to the Pact mock server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jakTMB6iPPAayiNJ7_LIUA.png" /></figure><p>4. When the tests are run, a contract JSON file is created within the ‘target’ folder &gt; ‘pacts’ folder, capturing the expected interactions from the provider.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXC5vtmGcc-lxnK4KRVeCA.png" /></figure><p>5. Now, either manually upload it to the provider or use the plugin within the build file to automatically upload the contract file to the Pact Broker (a cloud service that maintains contracts and details). <br>Maven goal — mvn pact:publish</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51n5qmK9FdRRf0tnSidbPw.png" /><figcaption>Contract uploaded to the Pact Broker</figcaption></figure><p><strong>Provider Test:</strong></p><p>1. Add Pact configurations at the Provider class.<br><strong>@Provider — </strong>This annotation is employed to indicate the name of the provider service for which the contract test is conducted. The name specified at Consumer within the annotation @PactTestFor should align with the name specified here.<br><strong>@PactBroker — </strong>Provide the Pact Broker account and token details that downloads the contract files<br><strong>@PactFolder(“pacts”) </strong>— If the contract file exists in local, provide the folder name here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8j_pcWNfsmYcm_ZObRsxw.png" /></figure><p>2. Write the test to run the interactions from the contract file<br><strong>@BeforeEach</strong> will set the server details to make the interactions over this real micro-service<br><strong>@TestTemplate</strong> — Its part of the JUnit testing framework that allows to define a template for tests and then generates multiple tests.<br><strong>PactVerificationInvocationContextProvider</strong> — Each Pact test in the consumer represents an interaction in the contract file. This attribute will generate a test for each interaction found in the Pact files for the provider.<br><strong>@State — </strong>This<strong> </strong>annotation helps in setting up the required precondition or states on the provider to handle specific scenarios. The state name is already configured at the consumer mock object. Hence the name in provider should match with the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7s48l04Fb7J7shrvVdvooQ.png" /><figcaption>Writ2</figcaption></figure><p>2. Run the provider tests; it runs the tests from the contract file with the actual service and verifies the results in the contract file against the actual results from the service.<br>3. Now, let’s explore how the contract test is a game-changer.</p><blockquote>Suppose, at the provider, the price type is updated from INT to String for some reason (e.g., to include the currency sign). This change would break at the consumer because, as discussed above, the consumer (library) service reads this price and sums it up with its resource prices. The contract test will fail, indicating that the consumer is expecting the price to be an INT. This information is then passed on to the consumer to update the changes at their end, ensuring a smooth release without any issues in later stages.</blockquote><blockquote>We can consider another scenario: If the required product that the consumer is requesting doesn’t exist with the provider, and the consumer is expecting a response code of 404. If, for some reason, the producer makes changes later to respond with 200 and an empty response body, this will break at the consumer. Hence, such discrepancies are known from the contract test.</blockquote><p><strong>Contract tests over schema validation :<br></strong>While there is a presumption that schema validation can solve these issues, but contract testing is more than that. As discussed, the status code scenario above, and often the consumer might not be interested in thousands of values from the producer’s response; only a few of them would be required. If we go with schema validation, it has to be maintained, and unnecessary changes at the producer show as a failure to the consumer. Moreover, in the agile world, with producers and consumers making changes simultaneously leaves a scope for the issue slip</p><p><strong>References:</strong><br>- Pact Docs — <a href="https://docs.pact.io/">https://docs.pact.io/</a><br>- <a href="https://pactflow.io/how-pact-works/#slide-1">https://pactflow.io/how-pact-works/#slide-1</a><br>- Rahul Shetty Contract Testing <a href="https://www.udemy.com/course/microservices-contract-testing-with-pact/">Course</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0caddc08bed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Assertions Simplified]]></title>
            <link>https://medium.com/@santhoshshetty58/assertions-simplified-63a0f0b52952?source=rss-be54146a5b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/63a0f0b52952</guid>
            <category><![CDATA[fluentassertions]]></category>
            <category><![CDATA[assertj]]></category>
            <category><![CDATA[assertions]]></category>
            <dc:creator><![CDATA[Santhosh]]></dc:creator>
            <pubDate>Fri, 29 Dec 2023 09:51:32 GMT</pubDate>
            <atom:updated>2023-12-29T09:51:32.027Z</atom:updated>
            <content:encoded><![CDATA[<p>Assertions play a crucial role in software development and testing automation. Popular Java-based testing frameworks like JUnit, and TestNG provide various assertion methods, but they lack readability and maintainability.</p><p>Consider a scenario where multiple checks are to be performed, and using traditional assertion methods often results in numerous statements, making the test code less readable and harder to maintain. In the era of shift-left testing, where end-to-end tests are streamlined, maintaining concise yet expressive assertions is paramount.</p><p>Let’s see the power of advanced assertions with a quick example. For instance, we get a JSON response from an API call, and we deserialize it into an object, and the requirement is to perform the below assertions:</p><ul><li>Verify that the response is not null.</li><li>Check specific data in each field of the deserialized object.</li><li>Ensure that all response values are not null.</li><li>Validate that a specific attribute, like ‘id,’ is an integer greater than zero.</li></ul><p><strong>Below is the version in TestNG</strong></p><pre>Assert.assertNotNull(user, &quot;User object should not be null&quot;);<br>Assert.assertEquals(user.getId(), 123, &quot;User ID should be 123&quot;);<br>Assert.assertEquals(user.getUsername(), &quot;john_doe&quot;, &quot;Username should be &#39;john_doe&#39;&quot;);<br>Assert.assertEquals(user.getEmail(), &quot;john.doe@example.com&quot;, &quot;Email should be &#39;john.doe@example.com&#39;&quot;);<br>Assert.assertEquals(user.getStatus(), &quot;active&quot;, &quot;Status should be &#39;active&#39;&quot;);<br>// Additional assertions for all properties not being null<br>Assert.assertTrue(<br>  Stream.of(user.getId(), user.getUsername(), user.getEmail(), user.getStatus())<br>    .allMatch(Objects::nonNull),&quot;All user properties should not be null&quot;<br>   );  <br>Assert.assertTrue(user.getId() &gt; 0, &quot;User ID should be greater than 0&quot;);<br>Assert.assertTrue(user.getUsername().startsWith(&quot;john&quot;), &quot;Username should start with &#39;john&#39;&quot;);<br>Assert.assertFalse(user.getUsername().contains(&quot; &quot;), &quot;Username should not contain whitespace&quot;);</pre><p><strong>Here’s the version using AssertJ</strong></p><pre>Assertions.assertThat(user)<br>    .as(&quot;User object should not be null&quot;)<br>    .isNotNull()<br>    .extracting(User::getId, User::getUsername, User::getEmail, User::getStatus)<br>    .as(&quot;Check user properties&quot;)<br>    .containsExactly(123, &quot;john_doe&quot;, &quot;john.doe@example.com&quot;, &quot;active&quot;)<br>    .allSatisfy(value -&gt; Assertions.assertThat(value).isNotNull())<br>    .satisfies(id -&gt; {<br>              Assertions.assertThat((Integer) id)<br>                .as(&quot;User ID should be greater than 0&quot;)<br>                  .isGreaterThan(0);<br>    });</pre><p>The above examples showcase the varying levels of readability and maintainability among different assertion types.</p><blockquote>While TestNG / JUnit provides a solid foundation for testing, the readability and maintainability of our assertions start to diminish, especially as the number of assertions increases. Writing multiple assert statements using methods like assertTrue and assertEquals can make our test code verbose and harder to follow.</blockquote><blockquote>The same set of assertions written using <strong>AssertJ</strong> is chained together, providing a clear and concise representation of the expected conditions. The fluent nature of AssertJ allows us to create more business-readable assertions, enhancing both readability and maintainability.</blockquote><h3><strong>WELCOME to the world of AssertJ</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*O-VuJHiGMlJp_N5mLL38jw.png" /><figcaption>image source — Internet</figcaption></figure><ul><li>As we move towards more complex test scenarios and an increased focus on shift-left testing, adopting assertion libraries like AssertJ becomes crucial.</li><li>The chaining capabilities and business-friendly syntax empower test automation engineers to write assertions that read like documentation rather than traditional technical statements, making the test code more understandable and maintainable.</li></ul><p><strong>AssertJ Overview<br></strong>AssertJ is composed of several modules</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZcbEIyZOMwoPgAeB0K7EpQ.png" /><figcaption>image source — AssertJ docs</figcaption></figure><p><strong>Pre-requisite:</strong><br>Build your project by adding the following dependencies <strong>assertj-core</strong>, <strong>assertj-joda-time</strong><br><a href="https://mvnrepository.com/artifact/org.assertj/assertj-core">https://mvnrepository.com/artifact/org.assertj/assertj-core</a><br><a href="https://mvnrepository.com/artifact/org.assertj/assertj-joda-time">https://mvnrepository.com/artifact/org.assertj/assertj-joda-time</a></p><p><strong>Let’s Begin:</strong><br>Now let’s dive into the robust features of AssertJ, a versatile assertion library that offers comprehensive assertion types. <br>I categorized them into different types for easy understanding.</p><p><strong>Equal Assertions: <br></strong>Perform a myriad of equal operations with ease. AssertJ ensures you have the right tools for any comparison scenario, from basic equality checks to intricate object comparisons.</p><pre>assertThat(&quot;John Doe&quot;).isEqualTo(&quot;John Doe&quot;);<br>assertThat(&quot;John&quot;).isNotEqualTo(&quot;Doe&quot;);</pre><p><strong>Boolean Assertions:<br></strong>Simplify your conditional checks by using AssertJ to verify whether a condition evaluates to true or false. This straightforward yet powerful feature enhances the readability of your assertions.</p><pre>Boolean boolValue = true;<br>assertThat(boolValue).isTrue();<br>assertThat(boolValue).isNotEqualTo(false);</pre><p><strong>Null check Assertions:<br></strong>Performs the null check in a readable fashion</p><pre>String value=&quot;John&quot;;<br>String nullValue = null;<br>assertThat(value).as(&quot;Non Null Check&quot;).isNotNull();<br>assertThat(nullValue).as(&quot;Null Check&quot;).isNull();</pre><p><strong>String Assertions:<br></strong>Experience the exhaustive suite and real power of string assertion types in AssertJ. Whether you need to validate substrings, check for specific prefixes or suffixes, or perform case-insensitive comparisons</p><pre>String strValue=&quot;Happy New Year&quot;;<br>        assertThat(strValue)<br>                .describedAs(&quot;String Assertions&quot;)<br>                .isNotNull()<br>                .startsWith(&quot;Happy&quot;)<br>                .contains(&quot;New&quot;)<br>                .endsWith(&quot;Year&quot;)<br>                .isNotBlank()<br>                .isNotEmpty()<br>                .overridingErrorMessage(()-&gt;&quot;Custom Message..&quot;)<br>                .containsWhitespaces()<br>                .doesNotContainOnlyWhitespaces()<br>                .isMixedCase()<br>                .containsIgnoringWhitespaces(&quot;HappyNewYear&quot;)<br>                .hasSizeGreaterThan(5)<br>                .as(&quot;Input contains only the characters and space&quot;)<br>                .matches(&quot;^[a-zA-Z ]*&quot;)<br>                .describedAs(&quot;Input doesn&#39;t contain the numbers&quot;)<br>                .doesNotMatch(&quot;\\d.*&quot;)<br>                .isInstanceOf(String.class);<br>        assertThat(&quot;Game&#39;of&#39;Thrones&quot;).isEqualToNormalizingPunctuationAndWhitespace(&quot;GameofThrones&quot;);</pre><p><strong>Numeric Assertions:<br></strong>From basic comparisons like greater than or equal to more complex assertions such as checking for proximity between numbers, AssertJ ensures precision in your numeric validations</p><pre>int number=58;<br>assertThat(number)<br>  .describedAs(&quot;Numeric Assertions&quot;)<br>  .isPositive()<br>  .isNotNegative()<br>  .isNotZero()<br>  .isBetween(35,70)<br>  .isInstanceOf(Integer.class)<br>  .isEven()<br>  .isCloseTo(60, Offset.offset(2))<br>  .isCloseTo(52, Percentage.withPercentage(15))<br>  .isNotCloseTo(70,Percentage.withPercentage(5));</pre><p><strong>List-based iterable Assertions:<br></strong> AssertJ allows you to verify the content, order, and structure of these data streamlining your assertions on lists and other iterable collections</p><pre>List&lt;String&gt; languages= Arrays.asList(&quot;Java&quot;,&quot;Python&quot;,&quot;Ruby&quot;,&quot;Go&quot;);<br>List&lt;String&gt; spokenLanguage=Arrays.asList(&quot;English&quot;,&quot;Deutsch&quot;);<br>assertThat(languages)<br>  .hasSize(4)<br>  .hasSizeLessThan(6)<br>  .isNotEmpty()<br>  .isNotNull()<br>  .doesNotContainNull()<br>  .doesNotHaveDuplicates()<br>  .isInstanceOf(List.class)<br>  .doesNotContainAnyElementsOf(spokenLanguage)<br>  .withFailMessage(()-&gt;&quot;Input doen&#39;t matches criteria&quot;)<br>  .allMatch(s-&gt;s.matches(&quot;^[a-zA-Z]*&quot;))<br>  .containsExactly(&quot;Java&quot;,&quot;Python&quot;,&quot;Ruby&quot;,&quot;Go&quot;);</pre><p><strong>Map-based Assertions:<br></strong> Validate key-value pairs, check for the presence or absence of keys, and more in a readable manner.</p><pre>Map&lt;String, String&gt; sports=new HashMap&lt;&gt;();<br>sports.put(&quot;Cricket&quot;,&quot;England&quot;);<br>sports.put(&quot;Football&quot;,&quot;Germany&quot;);<br>sports.put(&quot;Hockey&quot;,&quot;India&quot;);<br>assertThat(sports)<br>  .hasSize(3)<br>  .containsKey(&quot;Cricket&quot;)<br>  .containsValue(&quot;India&quot;)<br>  .containsEntry(&quot;Football&quot;,&quot;Germany&quot;)<br>  .isInstanceOf(Map.class)<br>  .isNotNull()<br>  .satisfies(sport -&gt; assertThat(sport.size()&gt;2));</pre><p><strong>Object-based Assertions:<br></strong>In-depth validation of objects. Check individual properties, compare entire objects, and ensure that objects meet specific criteria.</p><pre>Student s1=new Student(&quot;James&quot;,24,&quot;Hyd&quot;);<br>Student s2=new Student(&quot;John&quot;,28,&quot;BLR&quot;);<br>Student s3=new Student(&quot;Rosy&quot;,26,&quot;Mum&quot;);<br>assertThat(s1)<br>  .isInstanceOf(Student.class)<br>  .as(&quot;%s age should be less than 35&quot;,s1.getName())<br>  .hasFieldOrProperty(&quot;age&quot;)<br>  .hasFieldOrPropertyWithValue(&quot;city&quot;,&quot;Hyd&quot;)<br>  .hasNoNullFieldsOrProperties()<br>  .extracting(s -&gt; s.getAge())<br>  .isEqualTo(24);</pre><p><strong>File-based Assertions:<br></strong>It is very useful when working with file-related functionalities in your tests.</p><pre>File fileObj= new File(System.getProperty(&quot;user.dir&quot;).concat(System.getProperty(&quot;file.separator&quot;)+&quot;Sample.txt&quot;));<br>assertThat(fileObj)<br>  .describedAs(&quot;File Assertions&quot;)<br>  .canRead()<br>  .canWrite()<br>  .isFile()<br>  .hasExtension(&quot;txt&quot;);</pre><p><strong>Exception-based Assertions:</strong><br>AssertJ simplifies the validation of exceptions. Clearly express expectations regarding thrown exceptions, their types, and associated messages, making your tests more robust.</p><pre>assertThatThrownBy(()-&gt;getException()).as(&quot;Check Exception&quot;).isInstanceOf(RuntimeException.class);<br>assertThatThrownBy(()-&gt;{throw new Exception(&quot;foo&quot;);}).hasMessage(&quot;foo&quot;);</pre><p><strong>Date and Time-based Assertions:<br></strong>AssertJ offers a range of assertions tailored for date and time comparisons, accommodating various formats.</p><pre>LocalDate date=new LocalDate(2023,1,1);<br>Assertions.assertThat(date)<br>  .hasYear(2023)<br>  .hasMonthOfYear(1)<br>  .hasDayOfMonth(1)<br>  .isBefore(new LocalDate(2024,1,1));</pre><p><strong>BDD Styled Assertions:</strong><br>Embrace a more human-readable format for your assertions with AssertJ’s Behavior-Driven Development (BDD) style.</p><pre>then(&quot;AssertJ&quot;)<br>  .satisfies(val-&gt;{<br>      assertThat(val).isNotNull();<br>      assertThat(val.length()).isGreaterThan(4);<br>   });</pre><p><strong>Soft Assertions:</strong><br>Handle multiple assertions in a single test gracefully with soft assertions.</p><pre>SoftAssertions softAssertions=new SoftAssertions();<br>softAssertions.assertThat(s1)<br>  .isInstanceOf(Student.class)<br>   .extracting(s -&gt; s.getName())<br>   .isEqualTo(&quot;James&quot;);<br>softAssertions.assertAll();</pre><p><strong>Custom Assertion handler:<br></strong>Tailor AssertJ to your specific needs by creating custom assertions. This will allow you to extend its capabilities.</p><p>This is the most beneficial feature of creating a customized assert class and preparing fluent assertions. With Shift left testing in place, we end up with minimal end-to-end (E2E) tests that cover the entire user flow and have numerous assertions. If we resort to writing individual assertion statements, our code appears messy, leading to a loss of maintainability.</p><p>For instance, after adding an item to the cart and being redirected to the cart page, we need to verify multiple things such as cart count, item count, price, total price, etc. Writing individual assertions for each of them requires extracting values from the UI, making the code less maintainable. However, with AssertJ, we can create a custom assert class and write fluent assertions that are both readable and maintainable. Although we need to prepare an additional custom assert class and a validator class, it is necessary to have business-readable assertions.</p><p>Let’s consider another example, where the user launches a product page and verifies if the brand, name, ID, availability, and cart count are as expected. Below are the steps to follow when writing the custom assert object.</p><p><a href="https://joel-costigliola.github.io/assertj/core/api/org/assertj/core/api/AbstractAssert.html"><strong>AbstractAssert</strong></a> is the out-of-the-box class that holds the actual result type and performs the assertion with the expected result. <br>1. Extend the custom assert class with the AbstractAssert class, which takes two generic inputs. The first is the custom assert class type, and the second is the type that holds your actual result, accessible inside your assertions with the reference key named ‘<strong><em>actual</em></strong>’. <br>2. Inject the actual result object via the constructor and write the assertion methods by passing the expected result as an argument that will read the actual result from the result object and perform the assertion.</p><p>Here is the custom assert class that we can build for each end-to-end (E2E) test and inject the actual result object, building it from any of the Page Object layers.</p><ul><li><strong><em>ProductPageAssert</em></strong> is the Custom Assert Class</li><li><strong><em>ProductPageValidator</em></strong> is the POJO class that holds the actual result details</li></ul><pre>public class ProductPageAssert extends AbstractAssert&lt;ProductPageAssert, ProductPageValidator&gt; {<br><br>    SoftAssertions assertions;<br>    private ProductPageAssert(ProductPageValidator productPageValidator) {<br>        super(productPageValidator, ProductPageAssert.class);<br>        assertions=new SoftAssertions();<br>    }<br><br>    public static ProductPageAssert assertThat(ProductPageValidator productPageValidator){<br>        return new ProductPageAssert(productPageValidator);<br>    }<br>    <br>    public ProductPageAssert productNameIs(String productName){<br>        assertions.assertThat(actual.getProductName()).isEqualTo(productName);<br>        return this;<br>    }<br>    public ProductPageAssert productCodeIs(String productCode){<br>        assertions.assertThat(actual.getProductCode()).isEqualTo(productCode);<br>        return this;<br>    }<br>    public ProductPageAssert productBrandIs(String productBrand){<br>        assertions.assertThat(actual.getProductBrand()).isEqualTo(productBrand);<br>        return this;<br>    }<br>    public ProductPageAssert productAvailabilityIs(String productAvailability){<br>        assertions.assertThat(actual.getProductAvailability()).isEqualTo(productAvailability);<br>        return this;<br>    }<br>    public ProductPageAssert matchesDefaultCartCount(){<br>        assertions.assertThat(actual.getCartCount()).isEqualTo(0);<br>        return this;<br>    }<br>    public void assertAll(){<br>        assertions.assertAll();<br>    }<br>}</pre><p>Then, in the test class, simply call the assertion methods in the custom assert method by chaining the assertions.<br>Below, you’ll find assertions written in a fluent style that enhances readability. However, using other assertion approaches may lead to the creation of multiple assert statements, thereby making the code complex to maintain and understand.</p><pre>  @Test(description = &quot;Test Assertions using AssertJ&quot;)<br>    public void verifyLoginPageSpec(){<br>        ProductPage productPage=ProductPage.getProductPage();<br>        productPage.loadProductPage();<br>        ProductPageAssert.assertThat(productPage.getValidator())<br>                .productNameIs(&quot;iPhone&quot;)<br>                .productCodeIs(&quot;product 11&quot;)<br>                .productAvailabilityIs(&quot;In Stock&quot;)<br>                .productBrandIs(&quot;Apple&quot;)<br>                .matchesDefaultCartCount()<br>                .assertAll();<br>    }</pre><p>Feel free to check out my code repository for additional details. You can fork the repository to explore and add more assertions: <a href="https://github.com/santhoshshetty/CodePlayground/tree/main/src/test/java/demo/assertJ">Code Playground Repository</a>.</p><blockquote>In <strong>conclusion</strong>, AssertJ brings immense value by offering a readable, maintainable, and expressive way to write assertions through its support for chaining assertions, business-driven syntax, and exhaustive assertion methods. These assertions are designed to reflect the logic and intent of the test scenario in a way that is easily understandable by both technical and non-technical stakeholders. This aligns with the trend of writing tests in a more abstract, business-centric manner, making the test suite a valuable source of documentation.</blockquote><p><strong>References:<br></strong><a href="https://assertj.github.io/doc/">https://assertj.github.io/doc/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63a0f0b52952" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Appium Groundbreaking changes]]></title>
            <link>https://medium.com/@santhoshshetty58/appium-groundbreaking-changes-e996d6de8139?source=rss-be54146a5b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e996d6de8139</guid>
            <category><![CDATA[appium-inspector]]></category>
            <category><![CDATA[appium]]></category>
            <category><![CDATA[appium-2]]></category>
            <category><![CDATA[appium-testing]]></category>
            <dc:creator><![CDATA[Santhosh]]></dc:creator>
            <pubDate>Fri, 11 Aug 2023 21:50:19 GMT</pubDate>
            <atom:updated>2023-08-11T21:50:19.393Z</atom:updated>
            <content:encoded><![CDATA[<p>Appium 2.0 is a big step in mobile app testing. It’s the latest version after Appium 1.x, and it brings many exciting changes. Testers can expect a transformation in the way they work on projects. The new version focuses on removing old features, adding improvements, and making Appium more powerful. <br>Jonathan Lipps announced the official release on July 5th, 2023 &gt; Appium 2.0 is now out of beta and ready to be used!</p><p>The blog covers the major changes introduced in Appium Server from version 1.x to 2.x and the migration of Appium Client from version 7.x.x to 8.x.x. To set up Appium 2.0, please refer to the <a href="https://medium.com/@santhoshshetty58/setting-up-appium-2-0-made-simple-your-step-by-step-guide-7ebe13e57669"><strong>blog</strong></a> post</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*y_UFcRS6Bf2dRbKcnlxFaA.png" /></figure><p><strong>What is Appium?</strong><br>Appium is a free and popular tool for testing mobile apps on iOS, Android, and Windows devices. It automates tests for different app types and works on real devices and emulators. The latest version, Appium 2.0, brings significant improvements, making it more reliable and robust for testing mobile apps.</p><blockquote><strong>Appium core team does not maintain Appium 1.x anymore since the 1st of January 2022</strong>. All recent versions of officially supported platform drivers are not compatible with Appium 1.x, and require Appium 2 to run. Please read the migration guide from 1. x to 2.0 to manage the Appium server</blockquote><p><strong>Unveiling Appium 2.0: </strong>A Pioneering Journey of Improvements, Feature Upgrades, and Deprecations</p><p><strong><em>Appium V1 =&gt; Appium V2</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jReq5ODhAxi0eKxzYdubuw.jpeg" /></figure><p><strong>Protocol support:<br></strong>Appium 1.x supports the “JSONWP” (JSON Wire Protocol) and “MJSONWP” (Mobile JSON Wire Protocol) as well as the W3C WebDriver Protocol to ensure compatibility between older Selenium/Appium clients and newer Appium servers. Now Java client supports Selenium 4, which means it is strictly W3C compliant. Hence with Appium 2.0, only the W3C protocol is supported.</p><p>The recommended way to provide capabilities for driver creation is to use specific option builders inherited from BaseOptions class. For example, XCUITestOptions to create a XCUITest driver instance or UiAutomator2Options to create an UiAutomator2 driver instance.</p><p><strong>Appium Base Path:</strong><br>The base path for the Appium server is now — ‘/’ (root)<br>Previously in Appium 1.x it was <a href="http://localhost:4723/wd/hub">http://localhost:4723/wd/hub</a>. Now we can access the appium server just with the IP address</p><blockquote><strong>Appium 2.0 reenvisions Appium as a platform where “drivers” and “plugins” can be easily created and shared independently.</strong></blockquote><p><strong>Appium Drivers:</strong><br>Appium drivers have been segregated from the Appium Server. In Appium 1.x all the drivers used to get installed at once when Appium Server was installed. There was no possibility to download a single driver required, all the drivers were mandatorily downloaded at once.<br><strong><em>Starting from Appium 2.0, drivers can be independently installed/uninstalled or updated</em></strong><em>.</em> For example, instead of waiting for a new release of the Appium server, we have the option to solely update the driver for XCUITest using CLI commands.</p><pre>appium driver install &lt;driver name&gt;</pre><p><strong>Appium plugins:</strong><br>Appium plugins are additional modules or extensions that could be integrated with the main Appium server to add extra features, enhance capabilities, or support specific testing scenarios.</p><p>The introduction of the Appium Plugins feature offers end users the flexibility to develop their own plugins and incorporate them into their projects. Additionally, users can publish these plugins to the package manager, making them accessible to the wider community. This remarkable feature allows you to customize existing Appium features or create entirely new ones, all without any tight coupling to your codebase. It opens up endless possibilities for enhancing and extending the capabilities of Appium to suit specific project needs.</p><p>Some of the notable plugins maintained by the Appium core team:</p><ul><li><strong>Gestures Plugin:</strong> <br>This is an Appium plugin designed to perform basic gestures using W3C Actions. More details can be found <a href="https://github.com/AppiumTestDistribution/appium-gestures-plugin">here</a></li><li><strong>Appium Device Farm plugin:</strong> <br>- Automatically detects connected Android, iOS Simulators, and Real devices before session creation and maintains it in the device pool.<br>- Dynamically allocates a free device from the device pool while creating a driver session.<br>- Updates the device pool with a new device during test execution.<br>- Allocates random ports for parallel execution.<br>Navigate to localhost:4723/device-farm once the appium server is started. More details can be found <a href="https://github.com/AppiumTestDistribution/appium-device-farm">here</a></li><li><strong>Wait Plugin:</strong><br>This is an Appium plugin designed to wait for elements to be present. More details can be found <a href="https://github.com/AppiumTestDistribution/appium-wait-plugin">here</a></li></ul><p><strong>Appium Desktop replaced with Appium Inspector:</strong><br>The inspector functionality of Appium Desktop has been moved to its own app: Appium Inspector. It’s fully compatible with standalone Appium 2.0 servers but also works with later versions of Appium 1.x servers. Appium Desktop itself has been deprecated and is not compatible with Appium 2.0.</p><p>Appium In addition to the app, Appium Inspector also has a browser version, accessible at <a href="https://inspector.appiumpro.com/"><strong><em>https://inspector.appiumpro.com</em></strong></a>. Note that in order to use the browser version with a local Appium server, you’ll need to first start the server with the — allow-cors flag.</p><p><strong>Unveiling What’s New in Appium 8.x.x: Enhanced Features and Updates<br>Enhanced Locator Methods:</strong><br>- All findBy* shortcut methods(e.g. findElementById, findElementByClassName, findElementByLinkText,…) were removed.<br>- Consider using findElement[s](By. or AppiumBy.) instead.<br>- MobileBy class has been deprecated. Consider using Appium By instead.</p><p><strong>Optimized Locator Strategy:</strong><br>- All locator names in AppiumBy have been aligned to follow the common (camelCase) naming strategy, e.g. MobileBy.AccessibilityId was changed to AppiumBy.accessibilityId.<br>- As part of changes in Selenium 4, class name selector strategy will not work in Appium. AppiumBy.className should be used instead of Selenium’s By.className now.</p><p><strong>Methods deprecated:</strong><br><strong>Touch Actions:</strong> The TouchAction and MultiTouchAction classes (AndroidTouchActions, iOSTouchActions) have been deprecated. Now use W3C Actions instead or the corresponding extension methods for the driver (if available). <br><strong>Appium Driver Methods:</strong> AppiumDriver methods resetApp, launchApp, and closeup have been deprecated</p><p><strong>Conclusion:</strong><br>Using the list provided above, we can smoothly transition our existing automated tests/scenarios from version 7 to 8. In version 8, the capabilities that previously enforced the usage of JWP on Appium drivers no longer have any impact. An exciting change in Appium Java Client v8 is the replacement of MobileElement with WebElement, allowing a unified framework to be utilized across all platforms (Web, Android, and iOS).</p><p>For optimal performance and bug fixes, it is highly recommended to update the Appium Java Client to the latest stable version and use Appium 2+. Additionally, installing the required drivers and plugins tailored to our specific needs will significantly enhance automation execution time.</p><p><strong>Reference Links:</strong><br><a href="https://appium.io/docs/en/2.0/intro/">https://appium.io/docs/en/2.0/intro/</a><br><a href="https://appium.io/docs/en/2.0/guides/migrating-1-to-2/">https://appium.io/docs/en/2.0/guides/migrating-1-to-2/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e996d6de8139" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Appium 2.0 Made Simple: Your Step-by-Step Guide]]></title>
            <link>https://medium.com/@santhoshshetty58/setting-up-appium-2-0-made-simple-your-step-by-step-guide-7ebe13e57669?source=rss-be54146a5b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ebe13e57669</guid>
            <category><![CDATA[appium-server]]></category>
            <category><![CDATA[appium-testing]]></category>
            <category><![CDATA[appium-installer]]></category>
            <category><![CDATA[appium-driver]]></category>
            <category><![CDATA[appium-plugins]]></category>
            <dc:creator><![CDATA[Santhosh]]></dc:creator>
            <pubDate>Fri, 11 Aug 2023 21:36:41 GMT</pubDate>
            <atom:updated>2023-08-11T21:36:41.495Z</atom:updated>
            <content:encoded><![CDATA[<p>Appium 2.0 is a big update to the Appium framework, introducing new features. It focuses on becoming a platform with independent driver and plugin ecosystems while removing old and deprecated functions.</p><p><strong>Appium 2.0 Server Setup:<br></strong>There are two options available for installing the Appium server environment. The first method involves manually installing individual components, such as the Appium server, drivers, plugins, and appium-doctor, using separate commands.</p><p>However, in this blog, we will focus on the second method, which utilizes the Appium Installer NPM Package.</p><blockquote><strong>This approach simplifies the installation process by guiding us through each step via the Appium CLI. You no longer need to remember specific commands, as the installer takes care of everything seamlessly and sequentially. Additionally, it automatically sets necessary environment variables, further streamlining the setup.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_DUszNSLVlYWIhgjfXGdvw.png" /></figure><p><strong>Get ready for a hassle-free installation experience. Happy Installing!</strong></p><ol><li><strong>Download the Latest Version of Node:</strong><br>Download the stable version of Node JS from its official <a href="https://nodejs.org/en/download">website</a> based on your OS.</li><li><strong>Verify Node and NPM Installation:</strong> <br>Open the terminal and enter “node -v” to check the Node.js version and “npm -v” for npm’s version. Note that npm is bundled with Node.js and should be automatically installed during the process.<br>The version I used during setup might differ from the current one, as newer versions may have been released by the time you attempt the setup.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*pPW4Idz-WB6HUEy-lcFIRA.jpeg" /></figure><p>3. <strong>Install Appium Installer Package:<br></strong>Obtain the Appium installer package by executing the provided command, which installs it globally.</p><pre>npm install appium-installer -g</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*R5JOSxvaTYTXflLVXs75Bw.jpeg" /></figure><p>4. <strong>Start Appium Installer and Setup:<br></strong>Launch the Appium installer using the given command to access various setup options. Follow the instructions for proper setup, skipping any steps that are already completed or unnecessary.</p><pre>appium-installer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*Os9dfErTGbRT_GKIMpJTsg.jpeg" /></figure><p>5. <strong>Set Up Android Environment:<br></strong>Set up the Android environment, which provides essential tools and infrastructure for communication with Android devices. Choose <em>‘Need help setting up Android Environment to run your Appium Test’</em> to download the required binaries and set up environment variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WEDGHCKL-cYybad1t1VRiA.jpeg" /></figure><p>6.<strong> Set Up iOS Environment:</strong><br>Choose <em>‘Need help setting up iOS Environment to run your Appium Test’</em> to download the required binaries and set up environment variables.</p><p>7. <strong>Select Target Devices and Browsers:<br></strong>Choose target devices for running your Appium tests, including both virtual and real devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ktpedwkWuN5Y-asU9xUl_g.jpeg" /></figure><p>Also, specify the browser setup for emulators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b8JuDeSIYmUqM1ydjIGF8Q.jpeg" /></figure><p>8. <strong>Install Appium Server: </strong><br>Selecting the option ‘Install Appium Server’ will download and install the latest Appium server, ensuring you have the most up-to-date version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijafR6P4LZPAQESmFZvZnw.png" /></figure><p>9. <strong>Install Appium Plugins:<br></strong>Opt for the ‘Install Appium Plugin’ option to view and select from a list of available Appium plugins that suit your requirements. Download the chosen plugins with a simple command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qzPIyPe7k33WSHTzmdxYMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wkFLqqbA2BKSmQN0a6inQg.png" /></figure><p>10.<strong> Run Appium Doctor:</strong><br>Use the ‘Run Appium Doctor’ option to verify if your Appium setup is successful and ready for running tests.</p><p>11. <strong>Download Appium Inspector:<br></strong>Download Appium Inspector from the official <a href="https://github.com/appium/appium-inspector/releases">website</a> according to your operating system. Install the Inspector and utilize it to connect to devices (real or emulated) and inspect elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFHcCZ5uVV6Qd18os4DMmQ.png" /></figure><p>12.<strong> Start Appium Server:<br></strong>Run the ‘appium’ command to start the Appium server, and you are all set to begin your Appium tests with version 2.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADqMiDxKGIR3FpmdUaDxAA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ebe13e57669" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Made Easy: Chrome for Testing and Selenium Manager Join Forces]]></title>
            <link>https://medium.com/@santhoshshetty58/testing-made-easy-chrome-for-testing-and-selenium-manager-join-forces-3e610764bc4a?source=rss-be54146a5b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e610764bc4a</guid>
            <category><![CDATA[chrome-for-testing]]></category>
            <category><![CDATA[selenium-4]]></category>
            <dc:creator><![CDATA[Santhosh]]></dc:creator>
            <pubDate>Sun, 06 Aug 2023 22:27:45 GMT</pubDate>
            <atom:updated>2023-08-08T06:48:34.734Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introducing Chrome for Testing: Your Ultimate Tool for Web App Testing!<br></strong>Guess what? There’s an amazing version of Chrome called <strong><em>“Chrome for Testing,” specially crafted for web app testing and automation</em></strong>. This article will reveal why the Chrome team thought of this idea and how it can be a game-changer for developers / QA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*QzWERB3-NrFO-hnMa4Y7mw.png" /></figure><p><strong>The Auto-Update Dilemma: Good for Users, Bad for Developers:<br>- </strong>Chrome has a cool auto-update feature that users really like. It makes sure they always have the newest and safest browser with all the latest features and fixes. If the browser updates itself while they’re testing, it can mess things up. <br>- Also, developers want to use a specific browser version for their tests. But auto-update doesn’t let them do that. So, using regular Chrome for automated testing might not work well. This creates a difference between what’s good for regular users and what’s good for developers doing tests.</p><blockquote>In summary, while auto-update is a great feature for everyday users, <br>it presents significant challenges for developers aiming to maintain consistency and control in their testing environments.</blockquote><p><strong>Finding Chrome Binaries with Specific Versions — Challenge:<br></strong>Apart from auto-updates, you might have noticed that it’s tough to find a Chrome binary with a specific version. Google intentionally doesn’t offer versioned Chrome downloads because they want users to always have the latest version automatically. This is great for users but can be a challenge for developers who need an older version to reproduce a bug.</p><p>One particular problem arises when using ChromeDriver for browser automation. You not only have to get a Chrome binary, but you also need a matching ChromeDriver binary to ensure compatibility.<br>To work around these issues, some developers resort to downloading Chromium binaries instead of Chrome, but this has its drawbacks. <br>1. These Chromium binaries may not be reliably available on all platforms. <br>2. They are separate from the Chrome release process, making it hard to link them to real Chrome versions. <br>3. Chromium is not exactly the same as Chrome.</p><p><strong>Introducing “Chrome for Testing” (CfT) — Your Special Chrome Version for Testing!<br></strong>Chrome for Testing is a new Chrome flavor that specifically targets web app testing and automation use cases.</p><ol><li>CfT is a dedicated version of Chrome made specifically for testing purposes.</li><li>It is not meant for regular users, so it won’t be found on Chrome’s download page.</li><li>Unlike regular Chrome, CfT does not auto-update, ensuring stability during testing.</li><li>It is independent of Chrome’s release channels (Stable, Beta, Dev, Canary). CfT tracks official Chrome release branches and is bundled with ChromeDriver.</li><li>It has a distinct visual indicator to differentiate it from regular Chrome, reminding users not to use it for regular browsing.</li><li>CfT follows the same release schedule as Chrome Stable/Beta but without certain browser functionalities like auto-updating.<br>It offers fewer long-term support guarantees, similar to Chrome Canary, but is perfect for testing and automation purposes.</li></ol><p><strong>Use cases: Maintaining Testing Consistency with CfT<br>-</strong>Let’s say you have a web application that works perfectly on Chrome version 114, but the current version is 115. Unfortunately, finding the right Chrome version for testing can be a real headache since Chrome doesn’t offer specific version downloads.<br>- To make matters worse, your application isn’t yet compatible with version 115, and when an update happens, your automated tests end up running on the wrong version.</p><p>With CFT, you can easily maintain the Chrome version you need (in this case, version 114). This allows you to do manual testing on the exact version required and also provides the driver file for smooth automation testing.</p><p><strong>Downloading CfT — Follow these steps:</strong><br>1. Assets page: Go to URL — <a href="https://googlechromelabs.github.io/chrome-for-testing/">https://googlechromelabs.github.io/chrome-for-testing/</a> and download the respective binary file and driver file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XItW_uQmeCA_N8FbYqrTdA.jpeg" /></figure><p>2. Node command: Open the terminal and provide the below commands</p><pre># Download a specific Chrome for Testing version.<br>npx @puppeteer/browsers install chrome@116.0.5793.0<br><br># Download the latest available ChromeDriver version-Canary(upcoming)<br>npx @puppeteer/browsers install chromedriver@canary</pre><p>3. JSON API endpoints — Refer to the following page for endpoint details <a href="https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints">https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints</a></p><p><strong>Selenium embraces Chrome for Testing:<br></strong>Now, here comes the best part — Selenium Manager! Starting from <strong><em>version</em></strong> <strong><em>4.11.0</em></strong>, it supports Chrome for Testing. It takes care of managing the right version of Chrome for our tests. We can tell Selenium Manager which Chrome version we want, and it handles everything — finding, downloading, and managing that specific version for us.</p><p><strong>Simplified Explanation of Selenium Manager’s Use Cases:<br>- No Browser Installed: </strong>When you don’t have any browser on your machine and don’t specify a version, Selenium Manager automatically considers the latest stable version. It downloads and installs the browser for you, making testing easy.<br>- <strong>Matching Local Version:</strong> If you have the latest stable version (e.g., 115) of the browser on your machine and want to run tests on that version, Selenium Manager downloads only the driver file and executes tests on your local browser.<br>- <strong>Specific Version Needed:</strong> If you don’t have any browser but want to run tests on a specific version (e.g., 113), Selenium Manager downloads the required browser binaries and driver files. It sets up Chrome for Testing to run your tests on that version.<br>- <strong>Testing on Different Versions:</strong> Suppose you have the latest version (e.g., 115) but want to test on older versions (e.g., 113 and 114). Selenium Manager will download the necessary binaries for 113 and 114. Your tests will run on Chrome for Testing, keeping your local browser unaffected.</p><ul><li><strong><em>CfT extends support from Chrome version 113 onward, with drivers now accessible via the CfT dashboard instead of the traditional Chromium download location (</em></strong><a href="https://chromedriver.chromium.org/downloads"><strong><em>https://chromedriver.chromium.org/downloads</em></strong></a><strong><em>), and Selenium retrieves them accordingly.</em></strong></li><li><strong><em>The possible impact of using older Selenium versions (Pre 4.11): <br>If you are working with Selenium versions that are older than 4.11 and you’re testing with the newer Chrome 115, there’s a possibility that your test scripts might stop working. This is because the older Selenium Manager searches for the driver file in an old </em></strong><a href="https://chromedriver.chromium.org/downloads"><strong><em>location</em></strong></a><strong><em> that’s no longer used in Chrome 115 and onwards. Instead, Chrome has a new </em></strong><a href="https://googlechromelabs.github.io/chrome-for-testing/"><strong><em>location</em></strong></a><strong><em> for the driver file starting from version 115. So, when you use the older Selenium with Chrome 115, it might end up using a driver file (latest version on the page i.e., 114) and this could cause compatibility issues and script failures. To avoid this problem, it’s recommended to use the latest version of Selenium.</em></strong></li></ul><pre>ChromeOptions options=new ChromeOptions();<br>options.setBrowserVersion(&quot;115&quot;);<br>//To run tests on 113 version<br>options.setBrowserVersion(&quot;113&quot;);<br>//To run tests on upcoming versions<br>options.setBrowserVersion(&quot;116.0.5793.0&quot;);  <br>//To run tests on upcoming versions that is in development<br>options.setBrowserVersion(&quot;dev&quot;);<br>//If you have 114 version browser in local and you want to run on 114 CfT<br>options.setBinary(&quot;..../chrome.exe&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K9CjON5y22huxWJiP7sS8g.png" /><figcaption>Selenium Manager downloads the binaries to the local .cache folder</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OxSBbMtQZbgwHfUJ45EagA.png" /><figcaption>Here you find the chrome.exe (114) that Selenium launches the browser</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8yB4PmQWc1j6WXVlwVs8Q.png" /><figcaption>Here you find the chromedriver.exe file that Selenium uses for running the tests</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AVyn_ny5MEQ-74MI1kWr9Q.jpeg" /></figure><blockquote>You might have a question — How Chromium is different from CfT?<br>Chromium is built from arbitrary revisions that don’t necessarily map to user-facing Chrome releases, whereas Chrome for Testing is a dedicated flavor of Chrome targeting the testing use case, without auto-update, integrated into the Chrome release process, made available for every Chrome release across all channels (Stable/Beta/Dev/Canary).</blockquote><p>In conclusion, <strong>Chrome for Testing (CfT)</strong> is a game-changer in testing and automation. It enables developers/testers to use specific Chrome versions, ensuring consistency in tests. With Selenium Manager’s support for CFT, managing browsers and versions becomes effortless. Whether it’s the latest stable version or upcoming releases get ready for seamless testing with CFT and Selenium Manager!</p><p><strong>Reference Links<br></strong><a href="https://googlechromelabs.github.io/chrome-for-testing/">https://googlechromelabs.github.io/chrome-for-testing/</a><br><a href="https://developer.chrome.com/blog/chrome-for-testing/">https://developer.chrome.com/blog/chrome-for-testing/</a><br><a href="https://www.selenium.dev/blog/2023/whats-new-in-selenium-manager-with-selenium-4.11.0/">https://www.selenium.dev/blog/2023/whats-new-in-selenium-manager-with-selenium-4.11.0/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e610764bc4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>