<?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 Clark Ewerton on Medium]]></title>
        <description><![CDATA[Stories by Clark Ewerton on Medium]]></description>
        <link>https://medium.com/@clarkewertonSilva?source=rss-48c6ffd6a8fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0K_WPn-2y1DoVzeQ5AU0vg.jpeg</url>
            <title>Stories by Clark Ewerton on Medium</title>
            <link>https://medium.com/@clarkewertonSilva?source=rss-48c6ffd6a8fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:32:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@clarkewertonSilva/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[Pipelines and Kubernetes: Connecting an Azure Pipeline to a Local ArgoCD Cluster]]></title>
            <link>https://medium.com/@clarkewertonSilva/pipelines-and-kubernetes-connecting-an-azure-pipeline-to-argocd-ecb37d019a24?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecb37d019a24</guid>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[kubernetes-argocd]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 00:38:37 GMT</pubDate>
            <atom:updated>2025-11-11T00:41:49.395Z</atom:updated>
            <content:encoded><![CDATA[<p>As part of my learning path to become a better QA, today I decided to touch base a bit with Devops area. The aim here is to connect an Azure Pipeline to an ArgoCD instance running locally on my Windows machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_L6QXqQD1c-ze2Ap" /><figcaption>Photo by <a href="https://unsplash.com/@kanhaiyasharma?utm_source=medium&amp;utm_medium=referral">Kanhaiya Sharma</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>What’s the idea?</blockquote><p>First, the idea is to learn how to set up a complete ArgoCD environment locally using the ArgoCD CLI. Second, to deploy an app on it. Third, to use an Azure Pipeline to update the app’s manifest in a GitHub repository and then sync it automatically through the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWdvmyHwXh0Pa39NhzEgiQ.png" /></figure><p>To do so please follow the instructions below:</p><h3><strong>Summary</strong></h3><ol><li>Prerequisites</li><li>Installing and Configuring ArgoCD on a Windows machine</li><li>Deploy an app on ArgoCD and sync it</li><li>Creating a tunnel through NGROK</li><li>Creating an Azure Pipeline to change the manifest of the app and sync it automatically</li><li><strong><em>Prerequisites</em></strong></li></ol><p>Considering that I’m using Windows machine, follow some considerations:</p><pre>1. Install Chocolatey to make easier the process to download and install <br>all the necessary packages<br>2. Make sure you have Docker Desktop installed. (It&#39;s necessary to Enable <br>Kubernetes through it)<br>3. Make sure you have Ubuntu 20.04 installed on your Windows (via WSL)<br>4. Install ArgoCD<br>5. You need to register on NGROK website and install it on your machine<br>6. Make sure you have access to Azure environment and be able to connect<br>your Github project to a Pipeline.</pre><p><strong><em>2. Installing and Configuring ArgoCD on a Windows machine</em></strong></p><p>Please follow the instructions below:</p><p>First, with Chocolatey, let’s download and install some libraries through PowerShell (make sure you run it as Administrator):</p><pre>choco install docker-desktop kubernetes-cli kind ngrok argocd-cli</pre><p>⚠️<strong>Note: </strong>if you already have Docker Desktop installed on your machine, please remove the ‘docker-desktop’ command</p><p>Second, make sure you have enable Kubernetes through Docker Desktop:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAMz4XAnJKaOCewgKzTG9A.png" /></figure><p>⚠️<strong>Note:</strong> if for some reason Docker Desktop cannot start the cluster (make sure you have installed the Ubuntu 20.04 version). It seems that versions above it have some compatibility issues with Docker Desktop on Windows.</p><p>To do so please follow the instructions of this forum:</p><p><a href="https://forums.docker.com/t/kubernetes-failed-to-start-docker-desktop-win-10/138011/22">Kubernetes failed to start docker desktop win 10</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*xlymWOQmODpRs7DFcPnxdg.png" /></figure><p>By the end of those steps, you should have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*qByeE7fcvpQGaL5u8tgjiQ.png" /></figure><p>Make sure to also enable that version of Docker Desktop to be like this <strong>(and Restart everything by the end of it):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8iyX83EctzFuFz1bomgXg.png" /></figure><p>With Kubernetes up and running along with those packages already installed please run the following command:</p><pre>kubectl get nodes  </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*3HkEt4k1j_FO6stJCvWlMA.png" /></figure><p>Now let’s install ArgoCD CLI:</p><pre>kubectl create namespace argocd<br>kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml</pre><p>Verify if it’s running (wait until pods have its status changed to <strong>‘Running’)</strong>:</p><pre>kubectl get pods -n argocd</pre><p>Now we need to expose ArgoCD on a port, I’m my case I’ll use <strong>port 8000.</strong></p><pre>kubectl port-forward svc/argocd-server -n argocd 8000:443</pre><p>That been said, you can now connect to ArgoCD interface by typing <a href="https://localhost:8000/">https://localhost:8000</a> on your browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XSXbuYLpH_AhxoBGK8wx3Q.png" /></figure><p>The credentials are:</p><pre>Username: admin<br>Password: to fetch password, you need to open Powershell and <br>          type the following command:<br><br>kubectl -n argocd get secret argocd-initial-admin-secret -o <br>jsonpath=&quot;{.data.password}&quot; | ForEach-Object { <br>[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($_))}</pre><p><strong><em>3. Deploy an app on ArgoCD and sync it</em></strong></p><p>I didn’t want to create an app from scratch; instead, I’m using an existing one from a GitHub repository. So I forked this repo: <a href="https://github.com/argoproj/argocd-example-apps">https://github.com/argoproj/argocd-example-apps</a> to my personal github. <strong>(Do the same for you ok?)</strong></p><p>Inside it, there’s an app called <em>Guestbook</em> with a manifest named guestbook-ui-deployment.yaml. This is the file we’re going to deploy on ArgoCD.</p><p>That’s exactly the piece of code that we going to deploy to ArgoCD. First we need to log in to ArgoCD by using CLI instead of UI ok?</p><p>Run the command (First log in, then deploy the app):</p><pre><br>argocd login &lt;host&gt; --username admin --password &lt;password&gt; --insecure<br><br>argocd app create guestbook --repo https://github.com/clark-ewerton/argocd-example-apps.git --path guestbook --dest-server https://kubernetes.default.svc --dest-namespace default</pre><p>Where &lt;host&gt; is localhost:8000 <strong>(however we are gonna change it through the next step to use a tunnel domain generated by NGROK)</strong></p><p>Finally we need to sync it:</p><pre>argocd app sync guestbook      </pre><p>The result will be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ww1YIoyBDXxuWG9Bq1RwYg.png" /></figure><p><strong><em>4. Creating a tunnel through NGROK</em></strong></p><p>⚠️<strong>Note:</strong> to do this step, make sure you have registered on the NGROK website and fetched your auth token.</p><pre>ngrok http https://localhost:8000  </pre><p>This will generate a domain like this:</p><p><a href="https://unsatisfactorily-peremptory-brendon.ngrok-free.dev/"><strong>https://unsatisfactorily-peremptory-brendon.ngrok-free.dev/</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpFo5I-ZsH60uuMi9KNTNA.png" /></figure><p>Then it should open in your browser the same app but with that domain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*ww1YIoyBDXxuWG9Bq1RwYg.png" /></figure><p>⚠️<strong>Note:</strong> Using --insecure and exposing ArgoCD with NGROK should only be done for local testing purposes.</p><p><strong><em>5. Creating an Azure Pipeline to change the manifest of the app and sync it automatically</em></strong></p><p>In this step, we’ll be covering the creation of a new repo on GitHub as well as an Azure Pipeline.</p><p>Please create in your personal Github a new repo in which we’ll create a .yml file within it. In my case, I created this file <a href="https://github.com/clark-ewerton/azurePipelines-integration-argoCD/blob/main/azure-pipelines.yml">https://github.com/clark-ewerton/azurePipelines-integration-argoCD/blob/main/azure-pipelines.yml</a></p><p>We’ll need this repo to connect to Azure Services afterwards.</p><p>The pipeline would have the following content:</p><pre>trigger:<br>  branches:<br>    include:<br>      - main<br><br>resources:<br>  repositories:<br>    - repository: manifests<br>      type: github<br>      name: clark-ewerton/argocd-example-apps<br>      endpoint: GitHub<br><br>variables:<br>- group: argocd<br><br>jobs:<br>- job: UpdateManifest<br>  displayName: &quot;Update Guestbook manifest&quot;<br>  pool:<br>    vmImage: &#39;ubuntu-latest&#39;  # Hosted Linux agent<br>  steps:<br>    - checkout: manifests<br>      persistCredentials: true<br><br>    - script: |<br>        set -e<br>        echo &quot;🔧 Updating Guestbook manifest with a new image...&quot;<br>        cd $(Pipeline.Workspace)/s/<br><br>        # Ensure the master branch exists locally<br>        git fetch origin master<br>        git checkout master<br><br>        echo &quot;🔄 Updating annotation to force sync: $TIMESTAMP&quot;<br>        TIMESTAMP=$(date +%Y-%m-%dT%H:%M:%S)<br>        yq e -i &quot;.metadata.annotations.force-sync = \&quot;${TIMESTAMP}\&quot;&quot; guestbook/guestbook-ui-deployment.yaml<br><br>        # Commit changes<br>        git config --global user.name &quot;azure-pipelines[bot]&quot;<br>        git config --global user.email &quot;azure-pipelines@dev.azure.com&quot;<br>        git add guestbook/guestbook-ui-deployment.yaml<br>        git commit -m &quot;Update Guestbook manifest with tag $NEXT_TAG&quot;<br><br>        # Push to GitHub<br>        git push origin master<br>      displayName: &quot;Update manifest with incremental tag&quot;<br><br>- job: ArgoCDSync<br>  displayName: &quot;Sync with ArgoCD via Windows agent&quot;<br>  dependsOn: UpdateManifest<br>  pool:<br>    name: Clark  # your self-hosted Windows agent<br>  steps:<br>    - powershell: |<br>        Write-Host &quot;⬇️ Installing ArgoCD CLI...&quot;<br>        Invoke-WebRequest -Uri &quot;https://github.com/argoproj/argo-cd/releases/latest/download/argocd-windows-amd64.exe&quot; -OutFile &quot;argocd.exe&quot;<br>      displayName: &quot;Download ArgoCD CLI&quot;<br><br>    - powershell: |<br>        Write-Host &quot;🔑 Logging in to ArgoCD...&quot;<br>        .\argocd.exe login https://$(ARGOCD_SERVER) --username $(ARGOCD_USERNAME) --password $(ARGOCD_PASSWORD) --insecure --grpc-web<br><br>        Write-Host &quot;🔄 Refreshing the app $(ARGOCD_APP)...&quot;<br>        .\argocd.exe app get $(ARGOCD_APP) --refresh<br><br>        Write-Host &quot;🔍 Checking app status for $(ARGOCD_APP)...&quot;<br>        $appInfo = .\argocd.exe app get $(ARGOCD_APP) --grpc-web --output json | ConvertFrom-Json<br>        $status = $appInfo.status.sync.status<br><br>        Write-Host &quot;Current sync status: $status&quot;<br><br>        if ($status -eq &quot;OutOfSync&quot;) {<br>          Write-Host &quot;⚠️ Application is OutOfSync. Starting sync...&quot;<br>          .\argocd.exe app sync $(ARGOCD_APP) --grpc-web --timeout 180<br>          .\argocd.exe app wait $(ARGOCD_APP) --health --timeout 180<br>          Write-Host &quot;✅ Sync completed successfully!&quot;<br>        }<br>        else {<br>          Write-Host &quot;✅ Application is already in sync. No action needed.&quot;<br>        }<br>      displayName: &quot;Sync ArgoCD only if OutOfSync&quot;</pre><p>Let’s break it down and undertand each piece of it. First of all, this pipeline has <strong>2 jobs</strong>: one responsible to update the file <a href="https://github.com/clark-ewerton/argocd-example-apps/blob/master/guestbook/guestbook-ui-deployment.yaml"><strong>guestbook-ui-deployment.yaml</strong></a><strong> </strong>and another one to connect on ArgoCD CLI and sync the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6mtiF8X_qc3HOyirSGdzg.png" /></figure><p>I had to split it into two jobs because of a specific limitation: do you remember that I had to create a tunnel using NGROK and creating a domain to localhost:8000? So, that domain <a href="https://unsatisfactorily-peremptory-brendon.ngrok-free.dev/"><strong>https://unsatisfactorily-peremptory-brendon.ngrok-free.dev/</strong></a><strong> </strong>is not accessible from the public Internet, it’s still only available on my Windows machine. That been said, we got a problem, because my Azure Pipeline can only connect to a domain that can be accessible from Internet unless I create<strong> a workaround</strong>: use a <strong>Self Hosted pool</strong> from Azure services.</p><p>⚠️<strong>Note: </strong>Make sure when you create a pipeline, please use the option “Github” and then connect that new repo you created with the yml into Azure ok?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*xvXbC1w2p3RQ7ERCmxmS8Q.png" /></figure><blockquote><strong>How does that works?</strong></blockquote><p>Basically I need to create kind of a tunnel between my local machine and Azure services (in practice, my Azure Pipeline will have direct connection to my machine). Of course, I could set up a VM through Azure itself or even using a EC2 on AWS fo rthat (but honestly I just wanted to do a simple demonstration here without making it too complex 😛).</p><p>That been said, how do you create this pool on Azure? You need to navigate into <strong>Project Settings -&gt; Agent pools</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmrq6xkyNiLrmiBIHYg7tg.png" /></figure><p>I created this one called “clark”. After that, you also need to create an Agent within it. You need to navigate into Create new Agent -&gt; select Windows (in my case)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bj04P7W_-0B3Xvzfqnu-Fw.png" /></figure><p>Then you need to run all these commands sequentially.</p><p>The Agent’s tunnel will be ready:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y441YVE3oKOo2h1WB8HNJA.png" /></figure><p>⚠️<strong>Note:</strong> It’s important to highlight that Azure Pipeline will only work if the Agent is running locally.</p><p>Here I declare the repo I’ll be using to update the manifest (that file <a href="https://github.com/clark-ewerton/argocd-example-apps/blob/master/guestbook/guestbook-ui-deployment.yaml"><strong>guestbook-ui-deployment.yaml</strong></a><strong>) </strong>and then I also mention the <strong>variables group </strong>used to make the pipeline connect into ArgoCD CLI:</p><pre>resources:<br>  repositories:<br>    - repository: manifests<br>      type: github<br>      name: clark-ewerton/argocd-example-apps<br>      endpoint: GitHub<br><br>variables:<br>- group: argocd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*46PD4Q_ARQpaRvFCW07-vg.png" /></figure><p>Now, the idea of this <strong>first job</strong> is to update spefically this part of the file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RUmuMf-BFGITJPO-o7Yjng.png" /></figure><p>By doing that, ArgoCD will automatically identify that something has changed on the app from its origin, then its status will be marked as <strong>“Out of Sync”. </strong>In other words,<strong> </strong>We update the annotation to trigger ArgoCD to detect a change, forcing a sync event.</p><pre>- job: UpdateManifest<br>  displayName: &quot;Update Guestbook manifest&quot;<br>  pool:<br>    vmImage: &#39;ubuntu-latest&#39;  # Hosted Linux agent<br>  steps:<br>    - checkout: manifests<br>      persistCredentials: true<br><br>    - script: |<br>        set -e<br>        echo &quot;🔧 Updating Guestbook manifest with a new image...&quot;<br>        cd $(Pipeline.Workspace)/s/<br><br>        # Ensure the master branch exists locally<br>        git fetch origin master<br>        git checkout master<br><br>        echo &quot;🔄 Updating annotation to force sync: $TIMESTAMP&quot;<br>        TIMESTAMP=$(date +%Y-%m-%dT%H:%M:%S)<br>        yq e -i &quot;.metadata.annotations.force-sync = \&quot;${TIMESTAMP}\&quot;&quot; guestbook/guestbook-ui-deployment.yaml<br><br>        # Commit changes<br>        git config --global user.name &quot;azure-pipelines[bot]&quot;<br>        git config --global user.email &quot;azure-pipelines@dev.azure.com&quot;<br>        git add guestbook/guestbook-ui-deployment.yaml<br>        git commit -m &quot;Update Guestbook manifest with tag $NEXT_TAG&quot;<br><br>        # Push to GitHub<br>        git push origin master<br>      displayName: &quot;Update manifest with incremental tag&quot;</pre><p>In parallel, the idea of this<strong> second</strong> <strong>job</strong> is to connect to ArgoCD through CLI, monitor the status of the app, identify that its status was marked as <strong>“Out of Sync”.</strong> Then syncing it.</p><p>The idea is that, by the end of the pipeline’s execution, we have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gMy4n5rIzILm1IKLKni7Dw.png" /></figure><pre>- job: ArgoCDSync<br>  displayName: &quot;Sync with ArgoCD via Windows agent&quot;<br>  dependsOn: UpdateManifest<br>  pool:<br>    name: Clark  # your self-hosted Windows agent<br>  steps:<br>    - powershell: |<br>        Write-Host &quot;⬇️ Installing ArgoCD CLI...&quot;<br>        Invoke-WebRequest -Uri &quot;https://github.com/argoproj/argo-cd/releases/latest/download/argocd-windows-amd64.exe&quot; -OutFile &quot;argocd.exe&quot;<br>      displayName: &quot;Download ArgoCD CLI&quot;<br><br>    - powershell: |<br>        Write-Host &quot;🔑 Logging in to ArgoCD...&quot;<br>        .\argocd.exe login https://$(ARGOCD_SERVER) --username $(ARGOCD_USERNAME) --password $(ARGOCD_PASSWORD) --insecure --grpc-web<br><br>        Write-Host &quot;🔄 Refreshing the app $(ARGOCD_APP)...&quot;<br>        .\argocd.exe app get $(ARGOCD_APP) --refresh<br><br>        Write-Host &quot;🔍 Checking app status for $(ARGOCD_APP)...&quot;<br>        $appInfo = .\argocd.exe app get $(ARGOCD_APP) --grpc-web --output json | ConvertFrom-Json<br>        $status = $appInfo.status.sync.status<br><br>        Write-Host &quot;Current sync status: $status&quot;<br><br>        if ($status -eq &quot;OutOfSync&quot;) {<br>          Write-Host &quot;⚠️ Application is OutOfSync. Starting sync...&quot;<br>          .\argocd.exe app sync $(ARGOCD_APP) --grpc-web --timeout 180<br>          .\argocd.exe app wait $(ARGOCD_APP) --health --timeout 180<br>          Write-Host &quot;✅ Sync completed successfully!&quot;<br>        }<br>        else {<br>          Write-Host &quot;✅ Application is already in sync. No action needed.&quot;<br>        }<br>      displayName: &quot;Sync ArgoCD only if OutOfSync&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecb37d019a24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Integrate Cypress with FTP, SFTP, and S3 for End-to-End Testing?]]></title>
            <link>https://medium.com/@clarkewertonSilva/how-to-integrate-cypress-with-ftp-sftp-and-s3-for-end-to-end-testing-4c1d1dbbaa77?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c1d1dbbaa77</guid>
            <category><![CDATA[sftp]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Sun, 29 Jun 2025 02:05:20 GMT</pubDate>
            <atom:updated>2025-06-29T02:05:20.482Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Testing file uploads and downloads can be a blind spot in E2E automation. While Cypress is a fantastic tool for testing web applications, it doesn’t natively handle backend operations like interacting with FTP, SFTP, or AWS S3 servers.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HXDVVek26962vJKa" /></figure><p>In this guide, we’ll build a complete solution from scratch. We won’t just write the tests; we’ll build a robust, secure, and fully automated CI/CD pipeline that runs our tests, handles credentials safely, and publishes beautiful, interactive test reports on every code change.</p><p>By the end of this article, you will have:<br>1. A Cypress project capable of testing FTP, SFTP, and S3 operations.<br>2. A secure setup for managing credentials locally and in CI.<br>3. A full GitHub Actions workflow that automates your tests.<br>4. A system that automatically generates and deploys professional Allure test reports to GitHub Pages.</p><p>You can find the full source code for this project in this [GitHub Repository](<a href="https://github.com/clark-ewerton/cypress-ftp-sftp-s3">https://github.com/clark-ewerton/cypress-ftp-sftp-s3</a>).</p><p>⚠️<strong>Note:</strong> We are using a public SFTP/FTP server from Internet itself. IP Addresses along with its credentials are not garanteed to be kept.</p><h3><strong>Part 1: The Foundation — Local Cypress Tests</strong></h3><p>The core of our solution lies in Cypress’s <strong><em>`cy.task()`</em></strong> command. This powerful feature allows our browser-based tests to execute code in the Node.js environment, giving us access to the backend libraries needed to communicate with our servers.</p><h4>Step 1: Writing the Test</h4><p>First, let’s look at our S3 test file, <strong>/cypress/e2e/s3.cy.js. </strong>The test logic is simple and readable, calling tasks for each backend operation.</p><pre><br>// cypress/e2e/s3.cy.js<br>describe(&#39;S3 End-to-End Test&#39;, () =&gt; {<br> it(&#39;should upload, download, verify, and delete an object from S3&#39;, function() {<br> // 1. Create a local file to upload<br> cy.writeFile(this.localUploadPath, this.fileContent);<br>// 2. Upload the file to S3<br> cy.task(&#39;s3Upload&#39;, { key: this.fileName, filePath: this.localUploadPath });<br>// 3. Download the file from S3<br> cy.task(&#39;s3Download&#39;, { key: this.fileName, downloadPath: this.localDownloadPath });<br>// 4. Verify the downloaded file&#39;s content<br> cy.readFile(this.localDownloadPath).should(&#39;equal&#39;, this.fileContent);<br>// 5. Delete the object from S3<br> cy.task(&#39;s3Delete&#39;, { key: this.fileName });<br> });<br>});</pre><h4>Step 2: Implementing the Tasks</h4><p>Next, we implement the s3Upload, s3Download and s3Delete tasks in the <strong>\cypress-ftp-sftp-s3\cypress.config.js. </strong>Here, we use the aws-sdk library to interact with S3.</p><pre>// cypress.config.js<br><br>const { defineConfig } = require(&#39;cypress&#39;);<br>const AWS = require(&#39;aws-sdk&#39;);<br>const fs = require(&#39;fs&#39;);<br><br>module.exports = defineConfig({<br>  e2e: {<br>    setupNodeEvents(on, config) {<br>      // Load environment variables from .env file<br>      require(&#39;dotenv&#39;).config();<br><br>      // Pass AWS credentials to the Cypress browser environment<br>      config.env.AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;<br>      // ... and so on for other AWS variables<br><br>      on(&#39;task&#39;, {<br>        s3Upload({ key, filePath }) {<br>          const s3 = new AWS.S3({<br>            accessKeyId: process.env.AWS_ACCESS_KEY_ID,<br>            secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,<br>            region: process.env.AWS_REGION<br>          });<br>          const fileContent = fs.readFileSync(filePath);<br>          const params = {<br>            Bucket: process.env.S3_BUCKET,<br>            Key: key,<br>            Body: fileContent<br>          };<br>          return s3.upload(params).promise();<br>        },<br>        // ... other tasks like s3Download and s3Delete<br>      });<br><br>      return config;<br>    },<br>  },<br>});</pre><h4>Step 3: Managing Credentials Securely</h4><blockquote>Security Warning: Never hardcode credentials in your source code.</blockquote><p>We use a .env file to store our sensitive keys locally. To make the project easy for others to use, we also create a .env.example file, which acts as a template.</p><p>Most importantly, we add .env to our .gitignore file to ensure our secrets are never committed to the repository</p><pre># .gitignore<br><br># Environment variables<br>.env<br><br># Dependencies<br>/node_modules</pre><h3>Part 2: Automation with GitHub Actions</h3><p>Now, let’s automate our tests. We’ll create a workflow file at .github/workflows/ci.yml.</p><p>This workflow will:</p><ol><li>Check out the code.</li><li>Install dependencies.</li><li>Run the Cypress tests.</li></ol><p>The key is how we provide credentials to the CI environment. We use GitHub Secrets.</p><pre># .github/workflows/ci.yml<br><br>name: Cypress Tests<br><br>on:<br>  push:<br>    branches: [ main ]<br>  pull_request:<br>    branches: [ main ]<br><br>jobs:<br>  run-tests:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout<br>        uses: actions/checkout@v3<br><br>      - name: Install dependencies<br>        run: npm install<br><br>      - name: Run Cypress tests<br>        run: npm run test<br>        env:<br>          # Public credentials can be hardcoded<br>          FTP_HOST: ftp.dlptest.com<br>          FTP_USER: dlpuser<br>          # ...<br>          <br>          # AWS credentials must be read from secrets<br>          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>          AWS_REGION: ${{ secrets.AWS_REGION }}<br>          S3_BUCKET: ${{ secrets.S3_BUCKET }}</pre><p>To make this work, you must go to your GitHub repository’s <strong>Settings &gt; Secrets and variables</strong> &gt; Actions and add your four AWS credentials as repository secrets.</p><h3>Part 3: Professional Polish with Allure Reports</h3><p>Running tests is good, but seeing the results is better. We’ll integrate Allure to generate beautiful, detailed reports.</p><h4>Step 1: Install and Configure Allure</h4><p>First, we install the necessary packages:</p><pre>npm install --save-dev @shelex/cypress-allure-plugin allure-commandline</pre><p>Then, we configure it in <strong>cypress.config.js</strong> and <strong>cypress/support/e2e.js.</strong></p><h4>Step 2: Update the CI Pipeline</h4><p>We’ll enhance our <strong>ci.yml</strong> file to become a two-stage pipeline. The first stage runs the tests and uploads the results as an artifact. The second stage downloads the artifact, generates the Allure report, and deploys it to GitHub Pages.</p><pre># .github/workflows/ci.yml (abbreviated)<br><br>jobs:<br>  run-tests:<br>    # ... (same as before) ...<br>      - name: Upload Allure results<br>        uses: actions/upload-artifact@v4<br>        if: always()<br>        with:<br>          name: allure-results<br>          path: target/allure-results<br><br>  deploy-report:<br>    name: Generate and Deploy Allure Report<br>    if: always()<br>    needs: [run-tests]<br>    runs-on: ubuntu-latest<br>    permissions:<br>      contents: write<br><br>    steps:<br>    - name: Download Allure results<br>      uses: actions/download-artifact@v4<br>      with:<br>        name: allure-results<br>        path: target/allure-results<br><br>    - name: Generate Allure Report<br>      uses: simple-elf/allure-report-action@v1.7<br>      # ... configuration ...<br><br>    - name: Deploy to GitHub Pages<br>      uses: peaceiris/actions-gh-pages@v3<br>      with:<br>        github_token: ${{ secrets.GITHUB_TOKEN }}<br>        publish_dir: allure-history<br>        publish_branch: gh-pages</pre><h4>Step 3: Enable GitHub Pages</h4><p>The final step is to tell GitHub to serve the content from our new <strong><em>gh-pages</em></strong> branch. In your repository, go to Settings &gt; Pages, select <strong><em>gh-pages</em></strong> as the source branch, and save.</p><h3>Conclusion</h3><p>We’ve gone from a simple testing problem to a complete, professional automation solution. We have secure, reliable tests for complex file operations, a fully automated CI/CD pipeline, and beautiful, shareable reports generated on every run.</p><p>This setup not only ensures the quality of your project but also serves as a powerful template for any future Cypress project requiring advanced backend interactions. 😉</p><p>As usual, here is the source code for mentioned project:</p><p><a href="https://github.com/clark-ewerton/cypress-ftp-sftp-s3">GitHub - clark-ewerton/cypress-ftp-sftp-s3: Cypress automation for FTP, SFTP, and S3, featuring CI/CD with GitHub Actions and Allure reports</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c1d1dbbaa77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How did I create an automation bot to upload videos from Google Drive to Youtube automatically?]]></title>
            <link>https://medium.com/@clarkewertonSilva/how-did-i-create-an-automation-bot-to-upload-videos-from-google-drive-to-youtube-automatically-8eb2e2413ef8?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/8eb2e2413ef8</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[apı]]></category>
            <category><![CDATA[youtube]]></category>
            <category><![CDATA[google]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Sun, 04 May 2025 23:53:25 GMT</pubDate>
            <atom:updated>2025-05-04T23:53:25.815Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Automate YouTube Uploads from Google Drive: Python Script + API Tutorial</em></p><h3>Motivation:</h3><p>I’m a traveller and in all the trips I go I like to record as many videos as possible. Those are backup automatically using my Google account to Google Drive. However, as the time goes by, my google Account starts to have full of video files and eventually I have to pay more space to keep those. Of course that sometimes I take some time off just to upload those 1 by 1 to my Youtube channel and so I can delete those videos afterwards to free space on google drive…</p><p>But we’re talking about hundreds of videos for me to upload manually, so the whole thing was becoming unpratical. 😉</p><h3>Solution:</h3><p>As I work with IT and I know a bit of language programming, I questioned myself: why not build an automation bot that triggers the whole upload by looking at a specific folder from my google drive? 😉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*s55Hban3dzPhUPQK" /></figure><p>Here we go…</p><p>To resolve this problem I’m using a code made in Python that connects Google Drive to Youtube:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2uqZSCCSK7MynujtL8dmcQ.png" /></figure><h3><strong>How to do that?</strong></h3><p><strong>Step 1: </strong>Install Python on your machine (in my case I’m using Windows)</p><p><strong>Step 2: </strong>Setup your Google Cloud Console to connect your google account with drive/youtube APIs…</p><p>Here are some steps that you need to do…</p><ol><li><strong>Create a project in </strong><a href="https://console.cloud.google.com/"><strong>Google Cloud Console</strong></a>.</li><li><strong>Activate the following APIs:</strong></li></ol><ul><li>Google Photos Library API</li><li>YouTube Data API v3</li></ul><ol><li><strong>Create credentials OAuth 2.0</strong>:</li></ol><ul><li>Tipo: <em>“Desktop app”</em>.</li><li>Download JSON (client_secret.json).</li></ul><ol><li><strong>Save JSON</strong> in the same folder as your .py script is.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IVRPZVW4uN13TKBQSzpx-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OmLdA_uVhuhFCVaxd7XGGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*SIToHvwGI-NQPew2Sw1D3g.png" /></figure><p>Make sure you add your google e-mail to the list of authorized test users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-qKTGpL0j9ovPDtWSz5rg.png" /></figure><p><strong>Step 3:</strong> Create a python file and paste the code below on it: (the file can have any name like upload.py for example)</p><pre>import os<br>import time<br>from datetime import datetime<br>from google.oauth2.credentials import Credentials<br>from google_auth_oauthlib.flow import InstalledAppFlow<br>from googleapiclient.discovery import build<br>from googleapiclient.http import MediaFileUpload<br>import httplib2</pre><pre># Configs<br>CLIENT_SECRET_FILE = &#39;client_secret.json&#39;<br>SCOPES = [<br>    &#39;https://www.googleapis.com/auth/drive.readonly&#39;,<br>    &#39;https://www.googleapis.com/auth/youtube.upload&#39;<br>]<br>DRIVE_FOLDER_ID = &#39;15RAcraCGdAL8f_RFNcAWnJLBGv82HncQ&#39;  # replace using the id of your folder<br>PRIVACY_STATUS = &#39;public&#39;  # &#39;public&#39;, &#39;unlisted&#39;, ou &#39;private&#39;<br>LOG_FILE = &#39;upload_log.txt&#39;<br>MAX_RETRIES = 3  # Retries<br>CHUNK_SIZE = 1024 * 1024 * 100  # 100MB per chunk (avoid timeout)</pre><pre># Logs<br>def log(message):<br>    timestamp = datetime.now().strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)<br>    log_entry = f&quot;[{timestamp}] {message}\n&quot;<br>    print(log_entry, end=&#39;&#39;)<br>    with open(LOG_FILE, &#39;a&#39;, encoding=&#39;utf-8&#39;) as f:<br>        f.write(log_entry)</pre><pre># Authentication<br>def get_credentials():<br>    flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)<br>    return flow.run_local_server(port=0)</pre><pre># List folder videos<br>def list_videos(drive_service):<br>    videos = []<br>    page_token = None<br>    query = f&quot;mimeType contains &#39;video/&#39; and &#39;{DRIVE_FOLDER_ID}&#39; in parents and trashed = false&quot;<br>    <br>    while True:<br>        response = drive_service.files().list(<br>            q=query,<br>            fields=&quot;nextPageToken, files(id, name, size)&quot;,<br>            pageToken=page_token<br>        ).execute()<br>        videos.extend(response.get(&#39;files&#39;, []))<br>        page_token = response.get(&#39;nextPageToken&#39;)<br>        if not page_token:<br>            break<br>    return videos</pre><pre># Upload to Youtube<br>def upload_to_youtube(youtube_service, file_path, title):<br>    media = MediaFileUpload(<br>        file_path,<br>        chunksize=CHUNK_SIZE,<br>        resumable=True,<br>        mimetype=&#39;video/*&#39;<br>    )<br>    request = youtube_service.videos().insert(<br>        part=&#39;snippet,status&#39;,<br>       body = {<br>        &quot;snippet&quot;: {<br>            &quot;title&quot;: &quot;Kampong Phluk Floating Village, Cambodia | Jun/2023&quot;,<br>            &quot;description&quot;: &quot;#Cambodia #asiatrip #kampong #asia&quot;,<br>            &quot;tags&quot;: [&quot;trip&quot;, &quot;asia&quot;, &quot;cambodia&quot;],  # Tags de busca<br>            &quot;categoryId&quot;: &quot;19&quot;, <br>            &quot;defaultLanguage&quot;: &quot;en&quot;,  # Idioma padrão<br>            &quot;defaultAudioLanguage&quot;: &quot;en&quot;,  # Idioma do áudio<br>            &quot;recordingLanguages&quot;: [&quot;pt&quot;, &quot;es&quot;, &quot;en&quot;]<br>        },<br>        &quot;status&quot;: {<br>            &quot;privacyStatus&quot;: &quot;public&quot;,  # &#39;public&#39;, &#39;private&#39;, &#39;unlisted&#39;<br>            &quot;selfDeclaredMadeForKids&quot;: False,  # Vídeo NÃO é para crianças<br>        },<br>    },<br>        media_body=media<br>    )<br>    response = None<br>    while response is None:<br>        status, response = request.next_chunk()<br>        if status:<br>            log(f&quot;Progress: {int(status.progress() * 100)}%&quot;)<br>    return response[&#39;id&#39;]</pre><pre># Main flow<br>def main():<br>    creds = get_credentials()<br>    drive_service = build(&#39;drive&#39;, &#39;v3&#39;, credentials=creds)<br>    youtube_service = build(&#39;youtube&#39;, &#39;v3&#39;, credentials=creds)<br>    <br>    videos = list_videos(drive_service)<br>    log(f&quot;📂 Total of videos on folder: {len(videos)}&quot;)</pre><pre>    for video in videos:<br>        video_name = video[&#39;name&#39;]<br>        video_size = int(video.get(&#39;size&#39;, 0)) / (1024 * 1024)  # Tamanho em MB<br>        temp_path = f&quot;temp_{video_name}&quot;<br>        <br>        if video_size &gt; 2000:  # Pular vídeos &gt; 2GB (limite do YouTube)<br>            log(f&quot;⚠️ Video too big ({video_size:.2f}MB): {video_name}&quot;)<br>            continue</pre><pre>        for attempt in range(MAX_RETRIES):<br>            try:<br>                log(f&quot;⬇️ Downloading ({attempt + 1}/{MAX_RETRIES}): {video_name} ({video_size:.2f}MB)&quot;)<br>                request = drive_service.files().get_media(fileId=video[&#39;id&#39;])<br>                with open(temp_path, &#39;wb&#39;) as f:<br>                    f.write(request.execute())</pre><pre>                log(f&quot;⏫ Sending to YouTube: {video_name}&quot;)<br>                video_id = upload_to_youtube(youtube_service, temp_path, video_name)<br>                log(f&quot;✅ Sucesso! ID: {video_id}&quot;)<br>                break</pre><pre>            except Exception as e:<br>                log(f&quot;❌ Fail (attempt {attempt + 1}): {str(e)}&quot;)<br>                if attempt == MAX_RETRIES - 1:<br>                    log(f&quot;🔴 Video has failed after {MAX_RETRIES} attempts: {video_name}&quot;)<br>            finally:<br>                if os.path.exists(temp_path):<br>                    os.remove(temp_path)<br>                    log(f&quot;🧹 Temporary file removed: {temp_path}&quot;)</pre><pre>    log(&quot;🎉 Process Finished!&quot;)</pre><pre>if __name__ == &#39;__main__&#39;:<br>    main()</pre><p>Hey… don’t worry if you didn’t understand a single line from the code below, also because you’re not supposed to understand that… 😉</p><p>You just need to update couple of line, first one is:</p><pre>DRIVE_FOLDER_ID = &#39;15RAcraCGdAL8f_RFNcAWnJLBGv82HncQ&#39;</pre><p>Replace that id by the one of your google drive folder e.g.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*0Yw6sCSG_Ox6xafMfdPL3g.png" /></figure><p>Then you have to update this info:</p><pre>body = {<br>        &quot;snippet&quot;: {<br>            &quot;title&quot;: &quot;Kampong Phluk Floating Village, Cambodia | Jun/2023&quot;,<br>            &quot;description&quot;: &quot;#Cambodia #asiatrip #kampong #asia&quot;,<br>            &quot;tags&quot;: [&quot;trip&quot;, &quot;asia&quot;, &quot;cambodia&quot;],<br>            &quot;categoryId&quot;: &quot;19&quot;, <br>            &quot;defaultLanguage&quot;: &quot;en&quot;,  # default language<br>            &quot;defaultAudioLanguage&quot;: &quot;en&quot;,  # default audio language<br>            &quot;recordingLanguages&quot;: [&quot;pt&quot;, &quot;es&quot;, &quot;en&quot;]<br>        },<br>        &quot;status&quot;: {<br>            &quot;privacyStatus&quot;: &quot;public&quot;,  # &#39;public&#39;, &#39;private&#39;, &#39;unlisted&#39;<br>            &quot;selfDeclaredMadeForKids&quot;: False,  # video for children?<br>        },<br>    },</pre><p>As you can see I’m hardcoding some values for my videos, so let’s say that I have 20 videos of Kampong Cambodia place, then all of them are gonna be uploaded to youtube with the same title, description etc.</p><p><strong>Step 4:</strong> Execute your .py file by double clicking on it and Python will trigger the whole process. The first thing it will do is to ask you to authenticate on your google account ok? After that he’ll start the download/upload process and that’s it.</p><p>You can comment on this article in case you find any problems ok? I may help you, cheers 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8eb2e2413ef8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apply Azure CI/CD Pipeline for your Cypress Testing with Mochawsome reports on GitHub Pages]]></title>
            <link>https://medium.com/@clarkewertonSilva/apply-azure-ci-cd-pipeline-for-your-cypress-testing-with-mochawsome-reports-on-github-pages-308a5ef8082a?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/308a5ef8082a</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Sun, 04 May 2025 02:19:49 GMT</pubDate>
            <atom:updated>2025-05-04T23:55:19.306Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Automate Cypress Tests, Centralize Mochawesome Reports, and Host Them Publicly with Azure Pipelines and GitHub Pages.</em></p><p>This article is a continuation of the one published here:</p><p><a href="https://medium.com/@clarkewertonSilva/building-a-robust-ci-cd-pipeline-for-multi-browser-cypress-testing-1cf10840f47c">Building a Robust CI/CD Pipeline for Multi-Browser Cypress Testing with GitHub Actions</a></p><p>However the idea now is to demonstrate how you can do the same thing using AzureDevops pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DTgeUvFxOH5Mbebnuf6cIw.png" /></figure><p>So we’ll skip the whole Cypress project concept as it was already explained in the article above. Let’s just focus now on the Azure pipeline alright?</p><p><strong>Create a New Pipeline</strong>:</p><ul><li>Go to your Azure DevOps project.</li><li>Select <strong>Pipelines</strong> &gt; <strong>New Pipeline</strong>.</li><li>Choose your repository source (e.g., GitHub, Azure Repos). In my case I’m using GitHub as the project is already published there.</li><li>Select <strong>YAML</strong> to configure the pipeline as code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*57aHrx2j3-V7vQ8c.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*azHvPWFdzATwSVG-hA_RgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_DrjusVu9rn6yWYGkEqCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4N8uEk7Z_l3D_60VZq1weQ.png" /></figure><p>We need to expand this to install dependencies set up Cypress, run tests, and publish results.</p><p>Here,how the YAML configuration to work with Cypress:</p><pre>trigger:<br>  branches:<br>    include:<br>      - main<br><br>pr:<br>  branches:<br>    include:<br>      - main<br><br>variables:<br>  nodeVersion: &#39;18.x&#39;<br><br>stages:<br>  - stage: CleanArtifacts<br>    displayName: &#39;Clean gh-pages branch&#39;<br>    jobs:<br>    - job: CleanArtifactsFromGhPages<br>      displayName: &#39;Clean artifacts from gh-pages branch&#39;<br>      pool:<br>        vmImage: &#39;ubuntu-latest&#39;<br>      steps:<br>        - checkout: self<br>          clean: true<br>          persistCredentials: true<br><br>        - script: |<br>            git config --global user.name &quot;azure-pipelines[bot]&quot;<br>            git config --global user.email &quot;azure-pipelines@dev.azure.com&quot;<br><br>            git fetch origin<br><br>            # verifies if gh-pages branch already exists<br>            if git ls-remote --exit-code --heads origin gh-pages; then<br>              echo &quot;gh-pages branch already exists. Perform checkout...&quot;<br>              git checkout gh-pages<br>            else<br>              echo &quot;gh-pages branch does not exist. Creating...&quot;<br>              git checkout --orphan gh-pages<br>              git rm -rf .<br>              echo &quot;Initialization of gh-pages&quot; &gt; index.html<br>              git add index.html<br>              git commit -m &quot;Init gh-pages&quot;<br>              git push origin gh-pages<br>            fi<br><br>            # Clean branch files<br>            git rm -rf . || true<br>            git clean -fxd<br>            git commit --allow-empty -m &quot;Complete cleanup of gh-pages&quot;<br>            git push origin gh-pages<br>          displayName: &#39;Verifies/creates and clean branch gh-pages&#39;<br><br>  - stage: CI<br>    dependsOn: CleanArtifacts<br>    displayName: &#39;Run Cypress Tests&#39;<br>    jobs:<br>      - job: CypressTests<br>        strategy:<br>          matrix:<br>            chrome:<br>              browser: chrome<br>            edge:<br>              browser: edge<br>        pool:<br>          vmImage: &#39;ubuntu-latest&#39;<br>        steps:<br>          - checkout: self<br><br>          - task: NodeTool@0<br>            inputs:<br>              versionSpec: $(nodeVersion)<br><br>          - task: Cache@2<br>            inputs:<br>              key: &#39;npm | &quot;$(Agent.OS)&quot; | package-lock.json&#39;<br>              restoreKeys: |<br>                npm | &quot;$(Agent.OS)&quot;<br>              path: $(HOME)/.npm<br><br>          - script: npm install<br>            displayName: &#39;Install dependencies&#39;<br><br>          - script: npm run lint:fix<br>            displayName: &#39;Run ESLint&#39;<br><br>          - script: |<br>              npx cypress run --browser $(browser) --spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js,cypress/e2e/api/authentication/loginAPI.cy.js&quot; --reporter mochawesome --reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true<br>            displayName: &#39;Run Cypress&#39;<br>            continueOnError: true<br><br>          - script: npm run report:merge<br>            displayName: &#39;Merge test reports&#39;<br><br>          - script: npm run report:generate<br>            displayName: &#39;Generate HTML report&#39;<br><br>          - task: PublishBuildArtifacts@1<br>            inputs:<br>              pathToPublish: &#39;cypress&#39;<br>              artifactName: &#39;cypress-artifacts-$(browser)&#39;<br>              publishLocation: &#39;Container&#39;<br>              condition: always()<br><br>  - stage: CD<br>    dependsOn: CI<br>    displayName: &#39;Publish to GitHub Pages&#39;<br>    jobs:<br>      - job: DeployAll<br>        pool:<br>          vmImage: &#39;ubuntu-latest&#39;<br>        steps:<br>          - checkout: self<br>            persistCredentials: true<br>            clean: true<br>            fetchDepth: 0<br><br>    # Download artifacts from both browsers (chrome and edge)<br>          - task: DownloadBuildArtifacts@0<br>            inputs:<br>              artifactName: &#39;cypress-artifacts-chrome&#39;<br>              downloadPath: $(Build.SourcesDirectory)/<br>          - task: DownloadBuildArtifacts@0<br>            inputs:<br>              artifactName: &#39;cypress-artifacts-edge&#39;<br>              downloadPath: $(Build.SourcesDirectory)/<br><br>          # Setup files to be pushed to gh-pages branch<br>          - script: |<br>              mkdir -p ./chrome/videos ./edge/videos<br>              mkdir -p ./chrome/screenshots ./edge/screenshots<br><br>              # Copies necessary files from chrome artifact<br>              find ./cypress-artifacts-chrome/videos -type f -name &quot;*.mp4&quot; -exec cp {} ./chrome/videos/ \;<br>              find ./cypress-artifacts-chrome/screenshots -type f -name &quot;*.png&quot; -exec cp {} ./chrome/screenshots/ \;<br>              cp -r ./cypress-artifacts-chrome/reports/mochawesome/* ./chrome/<br><br>              # Copies necessary files from edge artifact<br>              find ./cypress-artifacts-edge/videos -type f -name &quot;*.mp4&quot; -exec cp {} ./edge/videos/ \;<br>              find ./cypress-artifacts-edge/screenshots -type f -name &quot;*.png&quot; -exec cp {} ./edge/screenshots/ \;<br>              cp -r ./cypress-artifacts-edge/reports/mochawesome/* ./edge/<br>            displayName: &#39;Organize artifacts&#39;<br><br>          # Generates index.html (generic reports that is gonna redirect you to either chrome or edge)<br>          - script: |<br>              mkdir -p ./public<br>              node generate-index.js<br>              cp -r ./public/index.html ./<br>            displayName: &#39;Generate Index&#39;<br><br>          # Perform deploy to github Pages<br>          - script: |<br>              git config user.name &quot;azure-pipelines[bot]&quot;<br>              git config user.email &quot;azure-pipelines@bot.com&quot;<br><br>              git fetch origin gh-pages<br>              git checkout gh-pages || git checkout -b gh-pages<br>              #git reset --hard<br><br>              git add -f index.html ./chrome/ ./edge/<br>              git commit -m &quot;Deploy Cypress reports for ALL browsers&quot;<br>              git push origin gh-pages --force<br>            displayName: &#39;Deploy to gh-pages&#39;</pre><p>The idea is that the CI/CD pipeline will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*9lldLLbW3sEOdRA7.png" /></figure><p><strong>Step 1: Trigger the Pipeline</strong></p><pre>trigger:<br>  branches:<br>    include:<br>      - main<br><br>pr:<br>  branches:<br>    include:<br>      - main<br><br>variables:<br>  nodeVersion: &#39;18.x&#39;</pre><p>This part of the configuration triggers the pipeline whenever there is a new commit to the main branch or new PR. (Here,we can change this to include any feature branch too)</p><p>This is crucial for continuous integration, ensuring that tests run every time code is added or changed.</p><p><strong>Quick note:</strong> this pipeline will use a Node version of 18 to setup and run cypress tests ok?</p><p><strong>Step 2: Jobs of Pipeline</strong></p><p>There are somejobs section, with 3 jobs defined:</p><p>- clean_artifacts_from_gh-pages_branch</p><p>- CI</p><p>- CD</p><p>Let’s understand each section of the yaml file</p><pre>- stage: CleanArtifacts<br>    displayName: &#39;Clean gh-pages branch&#39;<br>    jobs:<br>    - job: CleanArtifactsFromGhPages<br>      displayName: &#39;Clean artifacts from gh-pages branch&#39;<br>      pool:<br>        vmImage: &#39;ubuntu-latest&#39;<br>      steps:<br>        - checkout: self<br>          clean: true<br>          persistCredentials: true<br><br>        - script: |<br>            git config --global user.name &quot;azure-pipelines[bot]&quot;<br>            git config --global user.email &quot;azure-pipelines@dev.azure.com&quot;<br><br>            git fetch origin<br><br>            # verifies if gh-pages branch already exists<br>            if git ls-remote --exit-code --heads origin gh-pages; then<br>              echo &quot;gh-pages branch already exists. Perform checkout...&quot;<br>              git checkout gh-pages<br>            else<br>              echo &quot;gh-pages branch does not exist. Creating...&quot;<br>              git checkout --orphan gh-pages<br>              git rm -rf .<br>              echo &quot;Initialization of gh-pages&quot; &gt; index.html<br>              git add index.html<br>              git commit -m &quot;Init gh-pages&quot;<br>              git push origin gh-pages<br>            fi<br><br>            # Clean branch files<br>            git rm -rf . || true<br>            git clean -fxd<br>            git commit --allow-empty -m &quot;Complete cleanup of gh-pages&quot;<br>            git push origin gh-pages<br>          displayName: &#39;Verifies/creates and clean branch gh-pages&#39;</pre><p>First and foremost, the job called <strong>Cleanartifactsfromgh-pages</strong> is responsible for <strong>deleting any existing files or folders</strong> on the gh-pages branch — the default branch used for GitHub Pages. This branch holds the structure for the final reports that will be generated at the end of the workflow. It’s crucial to ensure that this clean-up happens as <strong>the first step</strong> in the process. By clearing out any previous artifacts, we avoid conflicts or leftover files from earlier deployments, ensuring that the <strong>new reports</strong> are deployed cleanly and correctly.</p><p>Next job is <strong>CI</strong> which has many steps:</p><pre>- stage: CI<br>    dependsOn: CleanArtifacts<br>    displayName: &#39;Run Cypress Tests&#39;<br>    jobs:<br>      - job: CypressTests<br>        strategy:<br>          matrix:<br>            chrome:<br>              browser: chrome<br>            edge:<br>              browser: edge<br>        pool:<br>          vmImage: &#39;ubuntu-latest&#39;<br>        steps:<br>          - checkout: self<br><br>          - task: NodeTool@0<br>            inputs:<br>              versionSpec: $(nodeVersion)<br><br>          - task: Cache@2<br>            inputs:<br>              key: &#39;npm | &quot;$(Agent.OS)&quot; | package-lock.json&#39;<br>              restoreKeys: |<br>                npm | &quot;$(Agent.OS)&quot;<br>              path: $(HOME)/.npm<br><br>          - script: npm install<br>            displayName: &#39;Install dependencies&#39;<br><br>          - script: npm run lint:fix<br>            displayName: &#39;Run ESLint&#39;<br><br>          - script: |<br>              npx cypress run --browser $(browser) --spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js,cypress/e2e/api/authentication/loginAPI.cy.js&quot; --reporter mochawesome --reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true<br>            displayName: &#39;Run Cypress&#39;<br>            continueOnError: true<br><br>          - script: npm run report:merge<br>            displayName: &#39;Merge test reports&#39;<br><br>          - script: npm run report:generate<br>            displayName: &#39;Generate HTML report&#39;<br><br>          - task: PublishBuildArtifacts@1<br>            inputs:<br>              pathToPublish: &#39;cypress&#39;<br>              artifactName: &#39;cypress-artifacts-$(browser)&#39;<br>              publishLocation: &#39;Container&#39;<br>              condition: always()</pre><p>The <strong>CI (Continuous Integration)</strong> job will only be triggered <strong>if the “Cleanartifactsfromgh-pagesb” job completes successfully</strong>. This job will then use the <strong>latest version of Ubuntu</strong> to run the Cypress tests. Additionally, it utilizes a <strong>matrix strategy</strong>, which allows the tests to be executed <strong>in parallel</strong> across the selected browsers — in this case, <strong>Chrome</strong> and <strong>Edge</strong>.</p><pre>   - task: NodeTool@0<br>            inputs:<br>              versionSpec: $(nodeVersion)<br><br>          - task: Cache@2<br>            inputs:<br>              key: &#39;npm | &quot;$(Agent.OS)&quot; | package-lock.json&#39;<br>              restoreKeys: |<br>                npm | &quot;$(Agent.OS)&quot;<br>              path: $(HOME)/.npm<br><br>          - script: npm install<br>            displayName: &#39;Install dependencies&#39;<br><br>          - script: npm run lint:fix<br>            displayName: &#39;Run ESLint&#39;</pre><p>The piece of code above does the following:</p><ol><li><strong>Install Node.js</strong>: Ensures the correct Node.js version is available.</li><li><strong>Cache npm dependencies</strong>: Restores cached node_modules (if available) to avoid re-downloading packages.</li><li><strong>Install dependencies</strong>: Runs npm install (will use cached dependencies if possible).</li><li><strong>Run ESLint</strong>: Checks and fixes code style issues.</li></ol><pre>          - script: |<br>              npx cypress run --browser $(browser) --spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js,cypress/e2e/api/authentication/loginAPI.cy.js&quot; --reporter mochawesome --reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true<br>            displayName: &#39;Run Cypress&#39;<br>            continueOnError: true<br><br>          - script: npm run report:merge<br>            displayName: &#39;Merge test reports&#39;<br><br>          - script: npm run report:generate<br>            displayName: &#39;Generate HTML report&#39;</pre><p>Then we have the name of a workflow (Run Cypress), where we can run our tests in a web browser. There is here the continue-on-error flag set to true because even if our tests fail we want to run other workflow steps responsible for generating a report.</p><p>With Cypress execution finished, it will generate some important .json files which are pretty much the mochawesome reports. We’re gonna to merge it and generate HTML reports.</p><pre>          - task: PublishBuildArtifacts@1<br>            inputs:<br>              pathToPublish: &#39;cypress&#39;<br>              artifactName: &#39;cypress-artifacts-$(browser)&#39;<br>              publishLocation: &#39;Container&#39;<br>              condition: always()</pre><p>Finally let’s upload the artifacts with all pieces of information we need: <strong>videos files, screenshots files (if some scenario fails) and mochawsome reports.</strong></p><p>⚠️<strong>Note:</strong> As CI job use matrix, it’ll generate 2 artifacts by the end of the day:</p><ul><li>cypress-artifacts-chrome</li><li>cypress-artifacts-edge</li></ul><p>To top it off, let’s understand next job <strong>CD</strong> that has many steps:</p><pre># Download artifacts from both browsers (chrome and edge)<br>          - task: DownloadBuildArtifacts@0<br>            inputs:<br>              artifactName: &#39;cypress-artifacts-chrome&#39;<br>              downloadPath: $(Build.SourcesDirectory)/<br>          - task: DownloadBuildArtifacts@0<br>            inputs:<br>              artifactName: &#39;cypress-artifacts-edge&#39;<br>              downloadPath: $(Build.SourcesDirectory)/</pre><p>The <strong>CD (Continuous Deployment)</strong> job will only run <strong>if the “CI” job completes successfully</strong>. It uses the latest Ubuntu runner to deploy the test artifacts.</p><p>If the last step of <strong>CI</strong> job was to upload artifacts, now we have to <strong>download it</strong>, and also check its content each one for the browsers we used: chrome and edge.</p><pre>          # Setup files to be pushed to gh-pages branch<br>          - script: |<br>              mkdir -p ./chrome/videos ./edge/videos<br>              mkdir -p ./chrome/screenshots ./edge/screenshots<br><br>              # Copies necessary files from chrome artifact<br>              find ./cypress-artifacts-chrome/videos -type f -name &quot;*.mp4&quot; -exec cp {} ./chrome/videos/ \;<br>              find ./cypress-artifacts-chrome/screenshots -type f -name &quot;*.png&quot; -exec cp {} ./chrome/screenshots/ \;<br>              cp -r ./cypress-artifacts-chrome/reports/mochawesome/* ./chrome/<br><br>              # Copies necessary files from edge artifact<br>              find ./cypress-artifacts-edge/videos -type f -name &quot;*.mp4&quot; -exec cp {} ./edge/videos/ \;<br>              find ./cypress-artifacts-edge/screenshots -type f -name &quot;*.png&quot; -exec cp {} ./edge/screenshots/ \;<br>              cp -r ./cypress-artifacts-edge/reports/mochawesome/* ./edge/<br>            displayName: &#39;Organize artifacts&#39;</pre><p>The purpose of the <strong>Organize artifacts</strong> job is to locate the <strong>videos</strong> and <strong>reports.json</strong> files generated by Cypress and move them into separate folders. This helps keep everything <strong>organized</strong> before the final deployment to gh-pages.</p><pre>          # Generates index.html (generic reports that is gonna redirect you to either chrome or edge)<br>          - script: |<br>              mkdir -p ./public<br>              node generate-index.js<br>              cp -r ./public/index.html ./<br>            displayName: &#39;Generate Index&#39;</pre><p>This step is crucial because, at the end of the pipeline, we’ll have <strong>two separate </strong><strong>report.html files</strong> generated: one for <strong>Chrome</strong> and one for <strong>Edge</strong>. To keep things simple and organized, I’ve created a <strong>single </strong><strong>index.html</strong> page that contains links redirecting to both reports.</p><p>The file <strong>generate-index.js</strong> is located in the root folder of the project (feel free to check the code there). The primary purpose of this script is to generate the <strong>index.html</strong> file. This new file will then be deployed to the gh-pages branch, along with the <strong>videos</strong> and <strong>reports.json</strong>.</p><p>And finally the last step is to publish everything into GitHub Pages:</p><pre>          # Perform deploy to github Pages<br>          - script: |<br>              git config user.name &quot;azure-pipelines[bot]&quot;<br>              git config user.email &quot;azure-pipelines@bot.com&quot;<br><br>              git fetch origin gh-pages<br>              git checkout gh-pages || git checkout -b gh-pages<br><br>              git add -f index.html ./chrome/ ./edge/<br>              git commit -m &quot;Deploy Cypress reports for ALL browsers&quot;<br>              git push origin gh-pages<br>            displayName: &#39;Deploy to gh-pages&#39;</pre><ul><li><strong>Purpose</strong>: Pushes the organized artifacts and reports to the gh-pages branch (used by GitHub Pages for hosting).</li></ul><p><strong>Details</strong>:</p><ul><li><strong>Git Setup</strong>: Configures the pipeline bot’s identity for commits.</li><li><strong>Branch Handling</strong>:</li><li>Fetches the existing gh-pages branch.</li><li>Checks it out (or creates it if it doesn’t exist).</li><li><strong>Force Push</strong>:</li><li>Adds the new files (index.html, chrome/, edge/).</li><li>Commits with a descriptive message.</li><li>Uses --force to overwrite history (common for automated deployments to avoid merge conflicts).</li></ul><p>At last, we can check if everything is set up correctly. We can just change anything on YAML azue file and save it that it’ll trigger the whole thing:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rh9VFJMUGuXVdiuoqaY5tQ.png" /></figure><p>So in the end, the structure of folders on gh-pages branch will be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfvUg7hV5ZdnVxgUUuNZPg.png" /></figure><p>Great! Now let’s check report page on Github Pages out. It will be available on address: <a href="https://clark-ewerton.github.io/cypress-serverest-cicd/">https://clark-ewerton.github.io/cypress-serverest-cicd/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*am1XVjktlwRHEqtu.gif" /></figure><p>And that’s it! I hope you’ve enjoyed this entry and it will help you automate your E2E tests. Happy testing😉</p><p>As usual, here is the source code for mentioned project:</p><p><a href="https://github.com/clark-ewerton/cypress-serverest-cicd?source=post_page-----1cf10840f47c---------------------------------------">GitHub - clark-ewerton/cypress-serverest-cicd: A project to demonstrate expertise in Cypress, Design Patterns, CI/CD (GitHub Actions and Pages), Mochawesome Reports, and cross-browser testing.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=308a5ef8082a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Have you heard about Macaca Inspector for inspecting your mobile elements?]]></title>
            <link>https://medium.com/@clarkewertonSilva/have-you-heard-about-macaca-inspector-for-inspecting-your-mobile-elements-e387911e20e7?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/e387911e20e7</guid>
            <category><![CDATA[mobile-testing]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Thu, 01 May 2025 00:56:26 GMT</pubDate>
            <atom:updated>2025-05-01T00:56:26.008Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>An unexpected surprise when it comes to mobile test automation</blockquote><p>When I was a QA Junior back to 2019, I’ve joined a mobile project in which I had to automate a suite of testCases for Android.</p><p>I remembered that one of the most difficult things for me was to inspect the elements from Mobile screen specially because it was a webView one and it didn’t have any good locators, only XPATH in that case.</p><p>So, just out of curiosity, I started digging in and looking for any tools that could help me easily identify the xpath locators (apart from the already existing tools that we know for Android like: UIAutomator or even Appium Inspectors).</p><p>Then I came accross this weird and wonderful tool for me at that time called Macaca Inspector. This tool was developed by Chinese people. Here’s their main website: <a href="https://macacajs.github.io/">https://macacajs.github.io/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*GkDdKpy-coLCmlZ9-GBYpQ.png" /></figure><p><strong>One</strong> thing that I’d like to mention here is that nowadays, as far as I’m concerned, Maca Inspector is already <strong>deprecated</strong>, so if you really want to use it for your local automated mobile tests, keep in mind that you’ll need to switch your JAVA version to 8.</p><p>You can check it out the whole repository by accessing this link: <a href="https://github.com/macacajs/app-inspector">https://github.com/macacajs/app-inspector</a></p><p>Also the official page is: <a href="https://macacajs.github.io/app-inspector/">https://macacajs.github.io/app-inspector/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/0*qIrUJwJpxzDPnV67" /></figure><p>So here I am in 2025 trying to use this tool again as a memory revival let’s say 😅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/0*Is6uwlZaLXtIL-5v.gif" /></figure><p><strong>Macaca Inspector</strong></p><p>For Macaca inspector first thing you should be installed <a href="http://nodejs.org/en/">NodeJS</a></p><p>Then need to install Macaca Inspector with the following command</p><pre>$ npm i app-inspector -g</pre><p>Next, you have to connect your android/ios device(<em>for android ADB setup has to be done</em>) and run the below command to start Macaca inspector.</p><pre>app-inspector -u &lt;device uid&gt;</pre><p>The above command starts a local server and launch the appium inspector with a connected device view.</p><p>Navigate to the application screen and refresh the page to load the view on the browser. Click on the tree structure of the layout and you can find all the properties of element. Xpath also will be there..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*e0KLnMSInH0kBLeB.jpeg" /></figure><h3>Problems using it in 2025?</h3><p>I faced many challenges when trying to use it again, I almost gave up TBH (after few days of deep research, I realized the whole problem was the version of JDK I was using, basically I had to switch the JDK 17 to 8 temporarly for it).</p><p>I’m gonna list here all the possible problems I’ve got and what I did to resolve it, maybe it can be life saver for someone in the future 😏</p><p><strong>Note:</strong> I used Windows for these tests.</p><p>1-<strong> Cannot find test framework “mocha” in</strong></p><pre>Error: Cannot find test framework &quot;mocha&quot; in C:\Users\clark\OneDrive\Documentos\projetos\node_modules<br> at Runner.initFramework (C:\Users\clark\AppData\Roaming\npm\node_modules\macaca-cli\lib\run\index.js:80:13)<br> at C:\Users\clark\AppData\Roaming\npm\node_modules\macaca-cli\lib\run\index.js:44:10<br> at process.processTicksAndRejections (node:internal/process/task_queues:95:5)</pre><p>To resolve this one I had to use the follow command: Node.js v18.16.0</p><p>npm install mocha — save-dev</p><p><strong>2- app-debug.apk not found</strong></p><pre>C:\Users\clark&gt;app-inspector -u dcf1741e<br>&gt;&gt; uiautomator-client.js:42:14 [master] pid:17464 C:\Users\clark\AppData\Roaming\npm\node_modules\app-inspector\node_modules\uiautomatorwd\app\build\outputs\apk\debug\app-debug.apk not found, please resolve and reinstall android driver<br>Error: &gt;&gt; uiautomator-client.js:42:14 [master] pid:17464 C:\Users\clark\c<br>apk\debug\app-debug.apk not found, please resolve and reinstall android driver</pre><p>First of all, uiautomatorviewer is a legacy thing which means that only works until JAVA 8 as already stated before. With that in mind, you can use the following .bat script to resolve it:</p><pre>@echo off<br>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202<br>set PATH=%JAVA_HOME%\bin;%PATH%<br>cd C:\Users\clark\AppData\Roaming\npm\node_modules\app-inspector\node_modules\uiautomatorwd<br>gradlew.bat assembleDebug </pre><p>If by any chance it happens an error of invalid ssh keys like:</p><pre>&gt; Task :app:packageDebug FAILED<br><br>FAILURE: Build failed with an exception.<br><br>* What went wrong:<br>Execution failed for task &#39;:app:packageDebug&#39;.<br>&gt; A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable<br>   &gt; com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store &quot;C:\Users\clark\.android\debug.keystore&quot;: Invalid keystore format<br><br>* Try:<br>Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.<br><br>* Get more help at https://help.gradle.org</pre><p>You can run the following command to sort it out:</p><pre>del C:\Users\clark\.android\debug.keystore<br>keytool -genkeypair -alias androiddebugkey -keypass android -keystore C:\Users\clark\.android\debug.keystore -storepass android -dname &quot;CN=Android Debug,O=Android,C=US&quot; -validity 10000 -keyalg RSA -keysize 2048 -storetype JKS<br>keytool -list -v -keystore C:\Users\clark\.android\debug.keystore -storepass android</pre><p><strong>3- app-debug-androidTest.apk not found</strong></p><p>And lastly, in case you get an error like:</p><pre>&gt;&gt; uiautomator-client.js:61:14 [master] pid:7712 C:\Users\clark\AppData\Roaming\npm\node_modules\app-inspector\node_modules\uiautomatorwd\app\build\outputs\apk\<br>androidTest\debug\app-debug-androidTest.apk not found, please resolve and reinstall android driver</pre><p>Then you can also use the following .bat script to resolve it:</p><pre>@echo off<br>set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202<br>set PATH=%JAVA_HOME%\bin;%PATH%<br>cd C:\Users\clark\AppData\Roaming\npm\node_modules\app-inspector\node_modules\uiautomatorwd<br>gradlew.bat assembleAndroidTest</pre><p>Here’s more of the thread:</p><p><a href="https://github.com/macacajs/app-inspector/issues/193">app-debug.apk not found, please resolve and reinstall android driver · Issue #193 · macacajs/app-inspector</a></p><p>That’s it, of course that nowadays if you are working on an automated mobile testing project, things will be easier as you run your tests on a device farm. And Lambdatest, browserstack, saucelabs or other ones from the market allow you to inspect elements pretty easier so using Macaca Inspector becomes pointless.</p><p>But anyway, hope you guys liked this article. Cheers ;D.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e387911e20e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Zero to CI/CD: Appium Mobile Testing with GitHub Actions and Allure Reports]]></title>
            <link>https://medium.com/@clarkewertonSilva/from-zero-to-ci-cd-appium-mobile-testing-with-github-actions-and-allure-reports-1fd984a9a5c8?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fd984a9a5c8</guid>
            <category><![CDATA[appium]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Sun, 27 Apr 2025 23:42:40 GMT</pubDate>
            <atom:updated>2025-04-28T23:46:47.799Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Step-by-step guide to automate your Android tests with GitHub Actions, Allure reports, and scalable emulator management.</blockquote><p>I decided to write this article as a wake-up call — to myself.<br>After working as a QA for the past six years, I realized I hadn’t studied anything new in a while. I was stuck in the “same old, same old.” So I rolled up my sleeves, grabbed a cup of coffee, and got to work.</p><p>To get started, I created a simple project that could showcase my Appium knowledge while applying as many good practices and design patterns as possible. These were the tools used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*Ldrxjt0oyzuGIldEn1ZgoA.png" /></figure><p>This project became my personal lab — a playground to experiment, learn, and improve.</p><p>⚠️<strong>Note:</strong> The goal here isn’t to teach Appium from scratch. Instead, I want to give you a high-level overview of how I structured and automated the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j04KV3b68XmUMparY9le6A.png" /></figure><h3>🧠What I Wanted to Build</h3><p>First of all, the idea was to automate couple of scenarios (both positive and negative) on any public android APK — just enough to have some end-to-end tests running.</p><p>So I chose a great public app called <strong>Google Calculator. </strong>Below are the scenarios that I cover:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*2awDC_nolVr51MArKzXjmA.png" /></figure><p>To manage data, I’m using <strong>@DataProvider</strong> from TestNG.</p><p>After that, I focused on applying some <strong>clean design patterns</strong>, running everything inside a <strong>GitHub Actions pipeline</strong> with a <strong>multi-device setup</strong>, and finally <strong>generating reports</strong> and <strong>deploying them to GitHub Pages</strong>.</p><h3>🧱Project Structure</h3><p>To define the structure of this project, the first step was choosing which <strong>design patterns</strong> would make sense to apply. Here are the main ones I used:</p><p>✅ Page Object Pattern — Encapsulates page structure and user interactions, promoting reusability and maintainability in UI tests.</p><p>✅ Factory Design Pattern— Responsible for abstracting the creation of driver instances depending on platform and configuration.</p><p>✅ Strategy Design Pattern — To select between local and cloud execution.</p><p>✅ Configuration Files — Properties files to manage data from mobile</p><p>✅ GitHub Pages — Publishes test artifacts and videos for public access</p><p><strong>Final structure:</strong></p><pre>mobile-test-automation-lab/<br>├── src/<br>│ │ └── main/java/com/clarkewerton<br>│ │ │ │ │ │ └── config/<br>│ │ │ │ │ │ │ │ ├── Configuration.java<br>│ │ │ │ │ │ │ │ ├── ConfigurationManager.java<br>│ │ │ │ │ │ └── driver/<br>│ │ │ │ │ │ │ │ ├── DriverFactory.java<br>│ │ │ │ │ │ │ │ ├── IDriver.java<br>│ │ │ │ │ │ │ │ ├── Platform.java<br>│ │ │ │ │ │ │ │ └── manager/<br>│ │ │ │ │ │ │ │ │ │ ├── AndroidDriverManager.java<br>│ │ │ │ │ │ │ │ │ │ ├── IOSDriverManager.java<br>│ │ │ │ │ │ └── exception/<br>│ │ │ │ │ │ │ │ ├── PlatformNotSupportedException.java<br>│ │ │ │ │ │ └── locators/<br>│ │ │ │ │ │ │ │ ├── AndroidLocators.java<br>│ │ │ │ │ │ │ │ ├── IOSLocators.java<br>│ │ │ │ │ │ └── page_object/<br>│ │ │ │ │ │ │ │ ├── CalculatorPage.java<br>│ │ │ │ │ │ └── test/<br>│ │ │ │ │ │ │ │ ├── BaseTest.java<br>│ │ │ └── resources/<br>│ │ │ │ │ ├── log4j2.properties<br>│ │ │ │ │ └── config/<br>│ │ │ │ │ │ │── android.properties<br>│ │ │ │ │ │ │── cloud.properties<br>│ │ │ │ │ │ │── general.properties<br>│ │ │ │ │ │ │── ios.properties<br>│ │ │ └── test/java/com/clarkewerton<br>│ │ │ │ │ │ └── android/ # Test classes for Android app<br>│ ││ ││ ││ ││ │ ├── CalculatorTest.java<br>│ │ │ └── resources/<br>│ │ │ │ │ ├── testng-cloud.xml<br>│ │ │ │ │ ├── testng-local.xml<br>├── .github/workflows/cicd.yml # GitHub workflows (CI, actions)<br>├── app/googleCalculator.apk # APKs or app-related files<br>├── scripts/ # support scripts to initialize appium and create a second emulator device on githubactions<br>├── target/allure-reports # Generated reports (e.g., Allure)<br>│ ├── .gitignore<br>├── pom.xml # Maven configuration<br>└── README.md</pre><h3>📂 Project Structure Breakdown</h3><p>src/main/java/com/clarkewerton/ → Core framework code</p><ul><li>config/ → Project configuration (property management)</li><li>Configuration.java → Configuration model class</li><li>ConfigurationManager.java → Loads and manages .properties files</li><li>driver/ → Driver initialization and management logic</li><li>DriverFactory.java → Factory pattern for driver creation</li><li>IDriver.java → Interface for multi-platform drivers</li><li>Platform.java → Enum for supported platforms (Android/iOS)</li><li>manager/ → Platform-specific implementations</li><li>AndroidDriverManager.java → Android driver setup</li><li>IOSDriverManager.java → iOS driver setup</li><li>exception/ → Custom exceptions</li><li>PlatformNotSupportedException.java → Thrown for unsupported platforms</li><li>locators/ → Platform-specific element mappings</li><li>AndroidLocators.java → Android selectors</li><li>IOSLocators.java → iOS selectors</li><li>page_object/ → Page Objects (e.g., CalculatorPage.java)</li><li>test/ → Base test class (BaseTest.java)</li></ul><p>src/main/resources/ → Project resources</p><ul><li>log4j2.properties → Logging configuration</li><li>config/ → Environment/device-specific properties</li><li>android.properties / ios.properties → Platform configs</li><li>cloud.properties → Cloud testing configs (e.g., SauceLabs)</li></ul><p>src/test/ → Tests and execution configs</p><ul><li>android/ → Android test classes (e.g., CalculatorTest.java)</li><li>resources/ → TestNG configurations (testng-local.xml, testng-cloud.xml)</li></ul><p><strong>Key Files &amp; Directories</strong>:</p><ul><li>.github/workflows/cicd.yml → CI/CD pipeline (GitHub Actions)</li><li>scripts/ → Support scripts (Appium/emulator setup)</li><li>target/allure-reports/ → Allure-generated test reports</li><li>app/ → App binaries (e.g., googleCalculator.apk)</li><li>pom.xml → Maven dependencies and config</li></ul><h3>▶️ What’s Being Run?</h3><p>In this project, I created <strong>two testNG files</strong> — one for running in remote devices created in Ubuntu env (managed by GitHub Actions) and one for the sauceLabs:</p><ul><li><a href="https://github.com/clark-ewerton/cypress-serverest-cicd/blob/main/cypress/e2e/gui/authentication/loginGUI.cy.js">src/test/resources/t</a>estng-local.xml</li><li><a href="https://github.com/clark-ewerton/cypress-serverest-cicd/blob/main/cypress/e2e/gui/authentication/loginGUI.cy.js">src/test/resources/t</a>estng-cloud.xml</li></ul><p>In the pipeline, I’m running both of them with the following command:</p><pre>mvn test -Dsurefire.suiteXmlFiles=src/test/resources/testng-local.xml</pre><p>👉 Don’t worry about it right now. It’ll be explained further on the next steps😉.</p><h3>Define GitHub workflow</h3><p>We can run test locally, so let’s move on to automate its execution with <em>GitHub Actions</em> which will result in HTML report published on <em>GitHub Pages</em>. The goal here is to put the full <strong>CI/CD concept</strong> into practice.</p><p>Therefore I assume that you already has <em>GitHub</em> account and a repository for your project.</p><p>The idea here is to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*G0b5tIDZLbeANrb__Cwjjg.png" /></figure><p>The CI/CD pipeline will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*JPKCyd64sF1fsbSqH0kcYA.png" /></figure><p>⚠️<strong>Note:</strong> Please create an account for you on SauceLabs and replace the username/token in the <strong>cloud.properties</strong> file.</p><p>Next, in the project root folder create a directory .github/workflows and inside of it a cicd.yml file.</p><pre>name: Appium CICD Test<br><br>on: [push, pull_request]<br><br>env:<br>  JAVA_VERSION: &#39;17&#39;<br>  JAVA_DISTRIBUTION: &#39;temurin&#39;<br>  MAVEN_CACHE: maven<br><br>  ANDROID_PROFILE: Nexus 6<br>  ANDROID_TARGET: google_apis<br>  ANDROID_API_LEVEL: 28<br>  ANDROID_ARCH: x86_64<br><br>  ARTIFACT_NAME_REMOTE: allure-results-android-remote<br>  ARTIFACT_NAME_CLOUD: allure-results-android-cloud<br>  GH_PAGES_URL: https://clark-ewerton.github.io/mobile-test-automation-lab<br><br>defaults:<br>  run:<br>    shell: bash<br><br>jobs:<br>  # --------------------------<br>  # Android Tests on Emulator<br>  # --------------------------<br>  run-android-tests-remote:<br>    runs-on: ubuntu-latest<br>    outputs:<br>      maven_tests: ${{ steps.maven_tests.outcome }}<br><br>    steps:<br>      - name: Enable KVM<br>        run: |<br>          echo &#39;KERNEL==&quot;kvm&quot;, GROUP=&quot;kvm&quot;, MODE=&quot;0666&quot;, OPTIONS+=&quot;static_node=kvm&quot;&#39; | sudo tee /etc/udev/rules.d/99-kvm4all.rules<br>          sudo udevadm control --reload-rules<br>          sudo udevadm trigger --name-match=kvm<br><br>      - name: Checkout project<br>        uses: actions/checkout@v4<br><br>      - name: Set up JDK<br>        uses: actions/setup-java@v3<br>        with:<br>          distribution: ${{ env.JAVA_DISTRIBUTION }}<br>          java-version: ${{ env.JAVA_VERSION }}<br>          cache: ${{ env.MAVEN_CACHE }}<br><br>      - name: Build with Maven<br>        run: mvn install -DskipTests<br><br>      - name: Start Appium Server<br>        run: |<br>          chmod +x ./scripts/prepareAppiumServer.sh<br>          ./scripts/prepareAppiumServer.sh<br><br>      - name: Run tests on Android emulators<br>        id: maven_tests<br>        uses: reactivecircus/android-emulator-runner@v2<br>        with:<br>          api-level: ${{ env.ANDROID_API_LEVEL }}<br>          target: ${{ env.ANDROID_TARGET }}<br>          arch: ${{ env.ANDROID_ARCH }}<br>          profile: ${{ env.ANDROID_PROFILE }}<br>          script: |<br>            chmod +x ./scripts/start_emulator_2.sh<br>            ./scripts/start_emulator_2.sh<br><br>            chmod +x ./scripts/uploadAPK.sh<br>            ./scripts/uploadAPK.sh<br><br>            mvn test -Dsurefire.suiteXmlFiles=src/test/resources/testng-local.xml || true<br><br>            echo &quot;Closing connection with emulator-5554&quot;<br>            adb -s emulator-5554 emu kill || true<br><br>            echo &quot;Closing connection with emulator-5556&quot;<br>            adb -s emulator-5556 emu kill || true<br><br>      - name: Upload results (emulador)<br>        if: always()<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: ${{ env.ARTIFACT_NAME_REMOTE }}<br>          path: ./target/allure-results<br><br>  # --------------------------<br>  # Android Tests on Sauce Labs<br>  # --------------------------<br>  run-android-tests-saucelabs:<br>    runs-on: ubuntu-latest<br>    outputs:<br>      maven_tests: ${{ steps.maven_tests.outcome }}<br><br>    steps:<br>      - name: Checkout project<br>        uses: actions/checkout@v4<br><br>      - name: Set up JDK<br>        uses: actions/setup-java@v3<br>        with:<br>          distribution: ${{ env.JAVA_DISTRIBUTION }}<br>          java-version: ${{ env.JAVA_VERSION }}<br>          cache: ${{ env.MAVEN_CACHE }}<br><br>      - name: Run tests on Sauce Labs<br>        run: mvn test -Dsurefire.suiteXmlFiles=src/test/resources/testng-cloud.xml<br><br>      - name: Upload results (Sauce Labs)<br>        if: always()<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: ${{ env.ARTIFACT_NAME_CLOUD }}<br>          path: ./target/allure-results<br><br>  # --------------------------<br>  # Generate and Publish reports<br>  # --------------------------<br>  deploy-report:<br>    if: always()<br>    name: Generate and deploy Allure Report<br>    needs: [run-android-tests-remote, run-android-tests-saucelabs]<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - name: Checkout gh-pages branch<br>        uses: actions/checkout@v4<br>        with:<br>          ref: gh-pages<br>          path: gh-pages<br>        continue-on-error: true<br><br>      - name: Download artifacts - Emulator<br>        if: always()<br>        uses: actions/download-artifact@v4<br>        with:<br>          name: ${{ env.ARTIFACT_NAME_REMOTE }}<br>          path: target/allure-results<br><br>      - name: Download artifacts - Sauce Labs<br>        if: always()<br>        uses: actions/download-artifact@v4<br>        with:<br>          name: ${{ env.ARTIFACT_NAME_CLOUD }}<br>          path: target/allure-results<br><br>      - name: Generate Allure Report<br>        uses: simple-elf/allure-report-action@master<br>        if: always()<br>        id: allure-report<br>        with:<br>          allure_results: target/allure-results<br>          gh_pages: gh-pages<br>          allure_report: allure-report<br>          allure_history: allure-history<br>          keep_reports: 20<br><br>      - name: Deploy to GitHub Pages<br>        if: always()<br>        uses: peaceiris/actions-gh-pages@v2<br>        env:<br>          PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}<br>          PUBLISH_BRANCH: gh-pages<br>          PUBLISH_DIR: allure-history<br><br>      - name: Post reports link<br>        if: always()<br>        uses: Sibz/github-status-action@v1<br>        with:<br>          authToken: ${{ secrets.GITHUB_TOKEN }}<br>          context: &#39;Test report&#39;<br>          state: ${{ needs.run-android-tests-remote.outputs.maven_tests == &#39;success&#39; &amp;&amp; needs.run-android-tests-saucelabs.outputs.maven_tests == &#39;success&#39; &amp;&amp; &#39;success&#39; || &#39;failure&#39; }}<br>          sha: ${{ github.event.pull_request.head.sha || github.sha }}<br>          target_url: ${{ env.GH_PAGES_URL }}/${{ github.run_number }}/</pre><p>Starting from a top, we’re defining <em>Appium CI CD Tests </em>workflow’s name and under which conditions it will be triggered. I’ve chosen to trigger it after pushing new commit into the main branch.</p><p>Next, there are somejobs section, with 3 jobs defined:</p><p>- run-android-tests-remote</p><p>- run-android-tests-saucelabs</p><p>- deploy-report</p><p>Let’s understand each one:</p><pre> # --------------------------<br>  # Android Tests on Emulator<br>  # --------------------------<br>  run-android-tests-remote:<br>    runs-on: ubuntu-latest<br>    outputs:<br>      maven_tests: ${{ steps.maven_tests.outcome }}<br><br>    steps:<br>      - name: Enable KVM<br>        run: |<br>          echo &#39;KERNEL==&quot;kvm&quot;, GROUP=&quot;kvm&quot;, MODE=&quot;0666&quot;, OPTIONS+=&quot;static_node=kvm&quot;&#39; | sudo tee /etc/udev/rules.d/99-kvm4all.rules<br>          sudo udevadm control --reload-rules<br>          sudo udevadm trigger --name-match=kvm<br><br>      - name: Checkout project<br>        uses: actions/checkout@v4<br><br>      - name: Set up JDK<br>        uses: actions/setup-java@v3<br>        with:<br>          distribution: ${{ env.JAVA_DISTRIBUTION }}<br>          java-version: ${{ env.JAVA_VERSION }}<br>          cache: ${{ env.MAVEN_CACHE }}<br><br>      - name: Build with Maven<br>        run: mvn install -DskipTests<br><br>      - name: Start Appium Server<br>        run: |<br>          chmod +x ./scripts/prepareAppiumServer.sh<br>          ./scripts/prepareAppiumServer.sh<br><br>      - name: Run tests on Android emulators<br>        id: maven_tests<br>        uses: reactivecircus/android-emulator-runner@v2<br>        with:<br>          api-level: ${{ env.ANDROID_API_LEVEL }}<br>          target: ${{ env.ANDROID_TARGET }}<br>          arch: ${{ env.ANDROID_ARCH }}<br>          profile: ${{ env.ANDROID_PROFILE }}<br>          script: |<br>            chmod +x ./scripts/start_emulator_2.sh<br>            ./scripts/start_emulator_2.sh<br><br>            chmod +x ./scripts/uploadAPK.sh<br>            ./scripts/uploadAPK.sh<br><br>            mvn test -Dsurefire.suiteXmlFiles=src/test/resources/testng-local.xml || true<br><br>            echo &quot;Closing connection with emulator-5554&quot;<br>            adb -s emulator-5554 emu kill || true<br><br>            echo &quot;Closing connection with emulator-5556&quot;<br>            adb -s emulator-5556 emu kill || true<br><br>      - name: Upload results (emulador)<br>        if: always()<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: ${{ env.ARTIFACT_NAME_REMOTE }}<br>          path: ./target/allure-results</pre><p>This GitHub Actions job (run-android-tests-remote) automates Android testing on an emulator in four key phases:</p><h4>1. Environment Setup</h4><pre>- Enables KVM acceleration for faster emulator performance  <br>- Checks out code and sets up Java 17 (Temurin) with Maven caching  <br>- Pre-builds the project with `mvn install -DskipTests`  <br>- Starts an Appium server via `prepareAppiumServer.sh`  </pre><h4>2. Emulator &amp; Test Execution</h4><pre>uses: reactivecircus/android-emulator-runner@v2  <br>with:  <br>  api-level: 28  # Android 9  <br>  profile: Nexus 6  <br>  script:  <br>    - Launches a second emulator (`start_emulator_2.sh`)  <br>    - Installs APK (`uploadAPK.sh`)  <br>    - Runs tests via TestNG (`testng-local.xml`)  <br>    - Force-kills emulators post-execution  </pre><p><em>Note</em>: The || true ensures workflow continues even if tests fail.</p><h4>3. Results Handling</h4><pre>- Uploads Allure results as artifacts (`allure-results-android-remote`)  <br>- Runs `if: always()` to capture data even if tests fail  </pre><h4>Key Architecture Decisions</h4><ul><li><strong>Parallel Emulators</strong>: Script starts <em>two emulators</em> (5554/5556) for potential parallel testing.</li><li><strong>Failure Resilience</strong>: Emulator cleanup and result uploads run unconditionally.</li><li><strong>Performance</strong>: KVM + Maven caching reduce CI time by ~40%.</li></ul><p>⚠️<strong>Note:</strong> I’m skipping the explanation of the job - run-android-tests-saucelabs because it speaks for itself.</p><p>To top it off, let’s understand next job <strong>deploy-reports</strong> that has many steps. This job will only run <strong>if the previous ones have completed successfully</strong>. It uses the latest Ubuntu runner to deploy the test artifacts.</p><p>At last, we can check if everything is set up correctly. To do that just commit all the changes and push to GitHub, which will trigger the action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4lxl7PS-ys-iVIHomleiyQ.png" /></figure><p>In SauceLabs, the execution will appear like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QXqmUHj6UknV_77dcmI0ZQ.png" /></figure><p>⚠️<strong>Note:</strong> Just remember to setup your account into SauceLabs and install the googleCalculator.apk in some device ok? Copy username and key and paste it on <strong>cloud.properties. </strong>Besides, you can use up to 1h on free account in SauceLabs.</p><p>Great! Enter a report page, you’ve just deployed. It will be available on address: <a href="https://clark-ewerton.github.io/mobile-test-automation-lab/">https://clark-ewerton.github.io/mobile-test-automation-lab/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yloENt7g_kncmAa8Mj_YJg.gif" /><figcaption>Allure Reports showing the results of test execution.</figcaption></figure><p>And that’s it! I hope you’ve enjoyed this entry and it will help you automate your E2E tests. I’m opened to suggestions as well 😉</p><p>As usual, here is the source code for mentioned project:</p><p><a href="https://github.com/clark-ewerton/mobile-test-automation-lab">GitHub - clark-ewerton/mobile-test-automation-lab: 🚀 Mobile Test Automation Lab | A scalable Appium + Java framework for Android/iOS testing. Features: ✔ Parallel testing | ✔ Allure Reports | ✔ CI/CD (GitHub Actions) ✔ Sauce Labs integration | ✔ DataProvider</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fd984a9a5c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Robust CI/CD Pipeline for Multi-Browser Cypress Testing with GitHub Actions]]></title>
            <link>https://medium.com/@clarkewertonSilva/building-a-robust-ci-cd-pipeline-for-multi-browser-cypress-testing-1cf10840f47c?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cf10840f47c</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation-tools]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[qa]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Tue, 15 Apr 2025 21:30:55 GMT</pubDate>
            <atom:updated>2025-04-29T01:22:23.679Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>How I automated cross-browser testing, reporting with videos, and deployment while driking coffee ☕?</blockquote><p>I decided to write this article as a wake-up call — to myself.<br>After working as a QA for the past six years, I realized I hadn’t studied anything new in a while. I was stuck in the “same old, same old.” So I rolled up my sleeves, grabbed a cup of coffee, and got to work.</p><p>To get started, I created a simple project that could showcase my Cypress knowledge while applying as many good practices and design patterns as possible.<br> I also wanted to integrate CI/CD, generate test reports (including videos!), and run end-to-end tests across multiple browsers.<br> This project became my personal lab — a playground to experiment, learn, and improve.</p><p>⚠️<strong>Note:</strong> The goal here isn’t to teach Cypress from scratch. Instead, I want to give you a high-level overview of how I structured and automated the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MPreuAxKw6GW6zgP" /><figcaption>Photo by <a href="https://unsplash.com/@olenkasergienko?utm_source=medium&amp;utm_medium=referral">Olena Bohovyk</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>🧠What I Wanted to Build</h3><p>First of all, the idea was to automate just <strong>three basic scenarios</strong> on any public web/API app — just enough to have some end-to-end tests running.</p><p>So I chose a great open-source app called <a href="https://serverest.dev/">ServeRest</a>, which provides both a front-end and an API:</p><ul><li>Front-end: <a href="https://front.serverest.dev/">https://front.serverest.dev</a></li><li>API: <a href="https://serverest.dev/">https://serverest.dev</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*JuhOwJGSzeSAOv1rCDQ8IQ.png" /></figure><p>The scenarios are (for both UI/API):<br>✅ Validate successful <strong>user signup and login</strong></p><p>❌ Validate error message when logging in with <strong>invalid credentials</strong></p><p>❌ Validate error message when logging in with an <strong>incorrect email format</strong></p><p>After that, I focused on applying some <strong>clean design patterns</strong>, running everything inside a <strong>GitHub Actions pipeline</strong> with a <strong>multi-browser setup</strong>, and finally <strong>generating reports</strong> and <strong>deploying them to GitHub Pages</strong>.</p><h3>🧱Project Structure</h3><p>To define the structure of this project, the first step was choosing which <strong>design patterns</strong> would make sense to apply. Here are the main ones I used:</p><p>✅ Data Factory Pattern — Generates dynamic test data</p><p>✅ Service Layer Pattern — Abstraction for API requests (For API)</p><p>✅ Custom Commands — Simplifies and reuses test actions (For GUI)</p><p>✅ Test Context Attachment — Attaches videos and artifacts to reports</p><p>✅ GitHub Pages — Publishes test artifacts and videos for public access</p><p><strong>Final structure:</strong></p><pre>cypress/<br>├── e2e/<br>│   ├── api/<br>│   │   └── authentication/<br>│   │       └── loginAPI.cy.js<br>│   └── gui/<br>│       └── authentication/<br>│           └── loginGUI.cy.js<br>├── fixtures/<br>├── support/<br>│   ├── commands<br>|   |      └── addContext.js<br>|   |      └── api_commands.js<br>|   |      └── gui_commands.js<br>│   └── e2e.js<br>├── factories/<br>│   └── userFactory.js<br>├── services/<br>│   └── userService.js<br>cypress.config.js<br>generate-index.js<br>.gitHub/<br>├── workflows/<br>│   └── cicd.yml<br>public/<br>└── videos/</pre><p>📘 Folder Breakdown:</p><ul><li><strong>Support:</strong> Utilities like custom commands and common hooks</li><li><strong>Fixture:</strong> Mocked data for testing (contract testing)</li><li><strong>E2E:</strong> End-to-end test specs (split into api/ and gui/)</li><li><strong>factories:</strong> Data factory layer for dynamic test data creation using Faker</li><li><strong>services:</strong> Service layer to abstract API calls</li><li><strong>context.js</strong>: Configures report context (e.g., attaching videos)</li><li><strong>public/videos:</strong> Folder where test videos are copied for publishing on GitHub Pages</li><li><strong>generate-index.js:</strong> Script that generates an index.html to list reports per browser</li><li><strong>workflows/cicd.yml:</strong> CI/CD pipeline configuration using GitHub Actions</li></ul><h3>▶️ What’s Being Run?</h3><p>In this project, I created <strong>two spec files</strong> — one for the UI and one for the API — and these are the ones being executed:</p><ul><li><a href="https://github.com/clark-ewerton/cypress-serverest-cicd/blob/main/cypress/e2e/gui/authentication/loginGUI.cy.js">cypress/e2e/gui/authentication/loginGUI.cy.js</a></li><li><a href="https://github.com/clark-ewerton/cypress-serverest-cicd/blob/main/cypress/e2e/api/authentication/loginAPI.cy.js">cypress/e2e/api/authentication/loginAPI.cy.js</a></li></ul><p>In the pipeline, I’m running both of them with the following command:</p><pre>npx cypress run --spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js&quot;,&quot;cypress/e2e/api/authentication/loginAPI.cy.js&quot; --reporter mochawesome --reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true</pre><p>👉 Don’t worry about all those parameters for now — I’ll break them down later in the article. 😉.</p><h3>Define GitHub workflow</h3><p>We can run test locally, so let’s move on to automate its execution with <em>GitHub Actions</em> which will result in HTML report published on <em>GitHub Pages</em>. The goal here is to put the full <strong>CI/CD concept</strong> into practice.</p><p>Therefore I assume that you already has <em>GitHub</em> account and a repository for your project.</p><p>The idea is that the CI/CD pipeline will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*8fm3XlFUaHp3thY_OmXVJQ.png" /></figure><p>Next, in the project root folder create a directory .github/workflows and inside of it a cicd.yml file.</p><pre>name: Cypress CI CD Tests<br><br>on:<br>  push:<br>    branches:<br>      - main<br>  pull_request:<br>    branches:<br>      - main<br><br>jobs:<br>  Clean_artifacts_from_gh-pages_branch:<br>    runs-on: ubuntu-latest<br>    permissions:<br>      contents: write<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br>        with:<br>          ref: &#39;gh-pages&#39;<br><br>      - name: Clean gh-pages branch<br>        run: |<br>          # Configuração segura do Git<br>          git config --global user.name &quot;github-actions[bot]&quot;<br>          git config --global user.email &quot;github-actions[bot]@users.noreply.github.com&quot;<br>    <br>          # Remove all files except .git<br>          if [ -d &quot;.git&quot; ]; then<br>            git rm -rf . || true<br>            git clean -fxd<br>            git commit --allow-empty -m &quot;Complete cleanup of gh-pages&quot;<br>            git push origin gh-pages<br>          else<br>            echo &quot;Branch gh-pages empty or not initialized&quot;<br>          fi<br><br>  CI:<br>    runs-on: ubuntu-latest<br>    needs: Clean_artifacts_from_gh-pages_branch<br>    strategy:<br>      matrix:<br>        browser: [chrome, edge]<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br>        with:<br>          ref: &#39;main&#39;<br><br>      - name: Setup Node.js<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: 18<br><br>      - name: Cache node modules<br>        uses: actions/cache@v4<br>        with:<br>          path: ~/.npm<br>          key: ${{ runner.os }}-node-${{ hashFiles(&#39;package-lock.json&#39;) }}<br>          restore-keys: |<br>            ${{ runner.os }}-node-<br><br>      - name: Install dependencies<br>        run: npm install<br><br>      - name: Run Cypress tests<br>        run: |<br>          npx cypress run --browser ${{ matrix.browser }} --spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js&quot;,&quot;cypress/e2e/api/authentication/loginAPI.cy.js&quot; --reporter mochawesome --reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true<br><br>      - name: Merge test reports<br>        run: npm run report:merge<br><br>      - name: Generate HTML report<br>        run: npm run report:generate<br><br>      - name: Upload Cypress Screenshots<br>        if: always()<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: cypress-screenshots-${{ matrix.browser }}<br>          path: cypress/screenshots<br><br>      - name: Upload artifacts<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: cypress-artifacts-${{ matrix.browser }}<br>          path: |<br>            cypress/videos/<br>            cypress/screenshots/<br>            cypress/reports/mochawesome/<br>            mochawesome-report/<br><br>  CD:<br>    runs-on: ubuntu-latest<br>    needs: CI<br>    strategy:<br>      matrix:<br>        browser: [chrome, edge]<br>      # Force sequential execution<br>      max-parallel: 1 <br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br><br>      - name: Download artifacts<br>        uses: actions/download-artifact@v4<br>        with:<br>          name: cypress-artifacts-${{ matrix.browser }}<br>          path: ./<br><br>      - name: Verifies content of files after download<br>        run: |<br>          echo &quot;Listing downloaded files:&quot;<br>          ls -R ./cypress<br><br>      - name: Copy artifacts<br>        run: |<br>          mkdir -p ./public/${{ matrix.browser }}/videos<br>          mkdir -p ./public/${{ matrix.browser }}/screenshots<br>          mkdir -p ./public/${{ matrix.browser }}/mochawesome-report<br><br>          echo &quot;Copy mp4 videos and paste it into one folder&quot;<br>          ls -R ./cypress/videos/ || true<br>          find ./cypress/videos/ -name &quot;*.mp4&quot; -exec cp {} ./public/${{ matrix.browser }}/videos/ \;<br><br>          echo &quot;Content of ./public/videos after copy&quot;<br>          ls -R ./public/${{ matrix.browser }}/videos || true<br><br>          cp -r ./cypress/screenshots/* ./public/${{ matrix.browser }}/screenshots/ || true<br>          cp -r ./cypress/reports/mochawesome/* ./public/${{ matrix.browser }}/ || true<br>          cp -r ./cypress/mochawesome-report/* ./public/${{ matrix.browser }}/mochawesome-report/ || true<br><br>      - name: Generate Index Page<br>        run: |<br>          mkdir -p ./public<br>          node generate-index.js<br><br>      - name: Deploy to GitHub Pages<br>        uses: peaceiris/actions-gh-pages@v3<br>        with:<br>          github_token: ${{ secrets.GITHUB_TOKEN }}<br>          publish_dir: ./public<br>          keep_files: true<br>          user_name: &#39;github-actions[bot]&#39;<br>          user_email: &#39;github-actions[bot]@users.noreply.github.com&#39;</pre><p>Starting from a top, we’re defining <em>Cypress CI CD Tests </em>workflow’s name and under which conditions it will be triggered. I’ve chosen to trigger it after pushing new commit into the main branch.</p><p>Next, there are somejobs section, with 3 jobs defined:</p><p>- clean_artifacts_from_gh-pages_branch</p><p>- CI</p><p>- CD</p><p>Let’s understand each one:</p><pre>jobs:<br>  Clean_artifacts_from_gh-pages_branch:<br>    runs-on: ubuntu-latest<br>    permissions:<br>      contents: write<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br>        with:<br>          ref: &#39;gh-pages&#39;<br><br>      - name: Clean gh-pages branch<br>        run: |<br>          # Configuração segura do Git<br>          git config --global user.name &quot;github-actions[bot]&quot;<br>          git config --global user.email &quot;github-actions[bot]@users.noreply.github.com&quot;<br>    <br>          # Remove all files except .git<br>          if [ -d &quot;.git&quot; ]; then<br>            git rm -rf . || true<br>            git clean -fxd<br>            git commit --allow-empty -m &quot;Complete cleanup of gh-pages&quot;<br>            git push origin gh-pages<br>          else<br>            echo &quot;Branch gh-pages empty or not initialized&quot;<br>          fi</pre><p>First and foremost, the job called <strong>Clean_artifacts_from_gh-pages_branch</strong> is responsible for <strong>deleting any existing files or folders</strong> on the gh-pages branch — the default branch used for GitHub Pages. This branch holds the structure for the final reports that will be generated at the end of the workflow. It’s crucial to ensure that this clean-up happens as <strong>the first step</strong> in the process. By clearing out any previous artifacts, we avoid conflicts or leftover files from earlier deployments, ensuring that the <strong>new reports</strong> are deployed cleanly and correctly.</p><p>Above we define the name of a workflow ( Checkout code), which is responsible for checking out branch to ‘gh-pages’.</p><p>Second step will be executing the name of a workflow ( Chean gh-pages branch), which is responsible to do the deletion of folders and files. It also have some thread safe (in case it’s alredy empty, do not interrupt pipeline).</p><p>Next job is <strong>CI</strong> which has many steps:</p><pre>CI:<br>    runs-on: ubuntu-latest<br>    needs: Clean_artifacts_from_gh-pages_branch<br>    strategy:<br>      matrix:<br>        browser: [chrome, edge]<br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br>        with:<br>          ref: &#39;main&#39;<br><br>      - name: Setup Node.js<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: 18<br><br>      - name: Cache node modules<br>        uses: actions/cache@v4<br>        with:<br>          path: ~/.npm<br>          key: ${{ runner.os }}-node-${{ hashFiles(&#39;package-lock.json&#39;) }}<br>          restore-keys: |<br>            ${{ runner.os }}-node-<br><br>      - name: Install dependencies<br>        run: npm install<br><br>      - name: Run Cypress tests<br>        run: |<br>          npx cypress run --browser ${{ matrix.browser }} --spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js&quot;,&quot;cypress/e2e/api/authentication/loginAPI.cy.js&quot; --reporter mochawesome --reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true<br>        continue-on-error: true<br><br>      - name: Merge test reports<br>        run: npm run report:merge<br><br>      - name: Generate HTML report<br>        run: npm run report:generate<br><br>      - name: Upload Cypress Screenshots<br>        if: always()<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: cypress-screenshots<br>          path: cypress/screenshots<br><br>      - name: Upload artifacts<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: cypress-artifacts-${{ matrix.browser }}<br>          path: |<br>            cypress/videos/<br>            cypress/screenshots/<br>            cypress/reports/mochawesome/<br>            mochawesome-report/</pre><p>The <strong>CI (Continuous Integration)</strong> job will only be triggered <strong>if the “Clean_artifacts_from_gh-pages_branch” job completes successfully</strong>. This job will then use the <strong>latest version of Ubuntu</strong> to run the Cypress tests. Additionally, it utilizes a <strong>matrix strategy</strong>, which allows the tests to be executed <strong>in parallel</strong> across the selected browsers — in this case, <strong>Chrome</strong> and <strong>Edge</strong>.</p><pre>- name: Checkout code<br>        uses: actions/checkout@v4<br>        with:<br>          ref: &#39;main&#39;</pre><p>Above we define the name of a workflow ( Checkout code), which is responsible for checking out branch to ‘main’.</p><pre>- name: Setup Node.js<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: 18</pre><p><strong>Second step</strong> will be executing the name of a workflow (Setup Node js), which is responsible to define the version of Node to run Cypress.</p><pre>- name: Cache node modules<br>        uses: actions/cache@v4<br>        with:<br>          path: ~/.npm<br>          key: ${{ runner.os }}-node-${{ hashFiles(&#39;package-lock.json&#39;) }}<br>          restore-keys: |<br>            ${{ runner.os }}-node-</pre><p><strong>Third step</strong> will be executing the name of a workflow (Cache Node modules), which is responsible to avoid download same libraries of Node again by caching it.</p><pre>- name: Install dependencies<br>        run: npm install<br><br>      - name: Run Cypress tests<br>        run: |<br>          npx cypress run --browser ${{ matrix.browser }} --spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js&quot;,&quot;cypress/e2e/api/authentication/loginAPI.cy.js&quot; --reporter mochawesome --reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true<br>        continue-on-error: true</pre><p>Then we have the name of a workflow (Run Cypress tests), where we can run our tests in a web browser. There is here the continue-on-error flag set to true because even if our tests fail we want to run other workflow steps responsible for generating a report.</p><p>In order to make this step work we need to set up couple of things. In the terminal run following command to install <a href="https://github.com/adamgruber/mochawesome">mochawesome</a> dependencies:</p><pre>$ npm install --save-dev mocha cypress-multi-reporters mochawesome</pre><p>Next, in the <strong>cypress.config.js</strong> file define <em>mochawesome</em> reporter:</p><pre>const { defineConfig } = require(&#39;cypress&#39;)<br><br>module.exports = defineConfig({<br>  e2e: {<br>    baseUrl: &#39;https://front.serverest.dev&#39;,<br>    setupNodeEvents (on, config) {<br>      config.env.apiBaseUrl = &#39;https://serverest.dev&#39;<br>      return config<br>    }<br>  },<br>   video: true,<br>    screenshotOnRunFailure: true,<br>  retries: {<br>    runMode: 2,<br>    openMode: 0<br>  },<br>   reporter: &#39;mochawesome&#39;,<br>  reporterOptions: {<br>    reportDir: &#39;cypress/reports/mochawesome&#39;,<br>    overwrite: false,<br>    html: false,<br>    json: true<br>  }<br>})</pre><p>You may wonder why the html option is false . Don’t worry, that’s correct. The CLI command that’s defined in package.json will generate one report per test file. But as we need to have only one, big report we need to merge them. It’s only possible with JSON reports and mochawesome-merge library, which we add in a following step.</p><p>But that’s not everything. We need to assign a video file (which is created by default by Cypress) to each test result. Therefore add these lines to the ./cypress/support/commands/addContext.js file:</p><pre>import addContext from &#39;mochawesome/addContext&#39;<br><br>Cypress.on(&quot;test:after:run&quot;, (test, runnable) =&gt; {<br>    let videoName = Cypress.spec.name<br>    videoName = videoName.replace(/\.js.*$/, &#39;.js&#39;)<br>    const videoUrl = &#39;videos/&#39; + videoName + &#39;.mp4&#39;<br><br>    addContext({ test }, videoUrl)<br>})</pre><p>Now explaining further the meaning of the whole command:</p><pre>npx cypress run - browser ${{ matrix.browser }} - spec &quot;cypress/e2e/gui/authentication/loginGUI.cy.js&quot;,&quot;cypress/e2e/api/authentication/loginAPI.cy.js&quot; - reporter mochawesome - reporter-options reportDir=cypress/reports/mochawesome,overwrite=false,html=false,json=true</pre><ol><li>npx cypress run<br>Runs Cypress in headless mode (no GUI)</li><li>--browser ${{ matrix.browser }}<br>Specifies which browser to use<br>${{ matrix.browser }} is a GitHub Actions variable that will be replaced with either chrome or edge</li><li>--spec &quot;path1&quot;,&quot;path2&quot;<br>Runs only these specific test files:</li></ol><ul><li>GUI test: cypress/e2e/gui/authentication/loginGUI.cy.js</li><li>API test: cypress/e2e/api/authentication/loginAPI.cy.js</li><li>Paths are comma-separated</li></ul><ol><li>--reporter mochawesome</li></ol><ul><li>Uses the Mochawesome reporter for test results</li><li>(Alternative to Cypress’s default reporter)</li></ul><ol><li>--reporter-options<br>Configures Mochawesome with:</li></ol><ul><li>reportDir=cypress/reports/mochawesome: Saves reports to this directory</li><li>overwrite=false: Preserves previous reports (appends new ones)</li><li>html=false: Disables HTML report generation</li><li>json=true: Enables JSON output (used for your dashboard)</li></ul><p>As it was mentioned before, the cypress run --browser chrome CLI command generates multiple JSON reports. Therefore we need to merge them into one.</p><pre>- name: Merge test reports<br>        run: npm run report:merge<br><br></pre><p>To achieve it we need first install another <em>mochawesome</em> dependency:</p><pre>$ npm install --save-dev mochawesome-merge</pre><p>And add a new script to the package.json file:</p><pre>&quot;scripts&quot;: {<br>  ... ,<br>  &quot;report:merge&quot;: &quot;mochawesome-merge cypress/reports/mochawesome/*.json -o cypress/reports/mochawesome/merged_report.json&quot;,<br>}</pre><p>Great, now we have a single merged_report.json report file. Let’s generate an HTML report from that.</p><pre>- name: Generate HTML report<br>        run: npm run report:generate</pre><p>Again, for that we will need another dependency to be added:</p><pre>$ npm install --save-dev mochawesome-report-generator</pre><p>And inside of the package.json file add the last script:</p><pre>&quot;scripts&quot;: {<br>  ... ,<br> &quot;report:generate&quot;: &quot;marge cypress/reports/mochawesome/merged_report.json -f report -o cypress/reports/mochawesome&quot;</pre><p>And the last steps are to upload artifacts, in this case: <strong>merged_report.json, screenshots</strong> (if there’re some e2e failing) and <strong>videos </strong>to a zip file.</p><pre>- name: Upload Cypress Screenshots<br>        if: always()<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: cypress-screenshots<br>          path: cypress/screenshots<br><br>      - name: Upload artifacts<br>        uses: actions/upload-artifact@v4<br>        with:<br>          name: cypress-artifacts-${{ matrix.browser }}<br>          path: |<br>            cypress/videos/<br>            cypress/screenshots/<br>            cypress/reports/mochawesome/<br>            mochawesome-report/</pre><p>⚠️<strong>Note:</strong> As CI job use matrix, it’ll generate 2 artifacts by the end of the day:</p><ul><li>cypress-artifacts-chrome</li><li>cypress-artifacts-edge</li></ul><p>To top it off, let’s understand next job <strong>CD</strong> that has many steps:</p><pre>CD:<br>    runs-on: ubuntu-latest<br>    needs: CI<br>    strategy:<br>      matrix:<br>        browser: [chrome, edge]<br>      # Force sequential execution<br>      max-parallel: 1 <br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v4<br><br>      - name: Download artifacts<br>        uses: actions/download-artifact@v4<br>        with:<br>          name: cypress-artifacts-${{ matrix.browser }}<br>          path: ./<br><br>      - name: Verifies content of files after download<br>        run: |<br>          echo &quot;Listing downloaded files:&quot;<br>          ls -R ./cypress<br><br>      - name: Copy artifacts<br>        run: |<br>          mkdir -p ./public/${{ matrix.browser }}/videos<br>          mkdir -p ./public/${{ matrix.browser }}/screenshots<br>          mkdir -p ./public/${{ matrix.browser }}/mochawesome-report<br><br>          echo &quot;Copy mp4 videos and paste it into one folder&quot;<br>          ls -R ./cypress/videos/ || true<br>          find ./cypress/videos/ -name &quot;*.mp4&quot; -exec cp {} ./public/${{ matrix.browser }}/videos/ \;<br><br>          echo &quot;Content of ./public/videos after copy&quot;<br>          ls -R ./public/${{ matrix.browser }}/videos || true<br><br>          cp -r ./cypress/screenshots/* ./public/${{ matrix.browser }}/screenshots/ || true<br>          cp -r ./cypress/reports/mochawesome/* ./public/${{ matrix.browser }}/ || true<br>          cp -r ./cypress/mochawesome-report/* ./public/${{ matrix.browser }}/mochawesome-report/ || true<br><br>      - name: Generate Index Page<br>        run: |<br>          mkdir -p ./public<br>          node generate-index.js<br><br>      - name: Deploy to GitHub Pages<br>        uses: peaceiris/actions-gh-pages@v3<br>        with:<br>          github_token: ${{ secrets.GITHUB_TOKEN }}<br>          publish_dir: ./public<br>          keep_files: true<br>          user_name: &#39;github-actions[bot]&#39;<br>          user_email: &#39;github-actions[bot]@users.noreply.github.com&#39;</pre><p>The <strong>CD (Continuous Deployment)</strong> job will only run <strong>if the “CI” job completes successfully</strong>. It uses the latest Ubuntu runner to deploy the test artifacts.</p><p>What’s interesting here is the use of a <strong>matrix strategy</strong> combined with a special parameter: max-parallel: 1.<br> Although matrix jobs are usually run in <strong>parallel</strong>, this setting forces them to run <strong>sequentially</strong> — meaning it will deploy the reports from <strong>Chrome first</strong>, then from <strong>Edge</strong>.</p><p>Why is that important?<br> Because deploying to GitHub Pages involves git pull/push operations under the hood. If both jobs try to deploy at the same time, it can lead to <strong>race conditions</strong> where GitHub Actions fails to find references (e.g., error: could not lock ref).<br> So by enforcing a sequential run, we make the deployment process <strong>safer and more stable</strong>.</p><pre>- name: Checkout code<br>        uses: actions/checkout@v4<br></pre><p>Above we define the name of a workflow ( Checkout code), which is responsible for checking out branch to ‘main’.</p><pre>- name: Download artifacts<br>        uses: actions/download-artifact@v4<br>        with:<br>          name: cypress-artifacts-${{ matrix.browser }}<br>          path: ./<br><br>      - name: Verifies content of files after download<br>        run: |<br>          echo &quot;Listing downloaded files:&quot;<br>          ls -R ./cypress</pre><p>If the last step of <strong>CI</strong> job was to upload artifacts, now we have to <strong>download it</strong>, and also check its content.</p><pre>- name: Copy artifacts<br>        run: |<br>          mkdir -p ./public/${{ matrix.browser }}/videos<br>          mkdir -p ./public/${{ matrix.browser }}/screenshots<br>          mkdir -p ./public/${{ matrix.browser }}/mochawesome-report<br><br>          echo &quot;Copy mp4 videos and paste it into one folder&quot;<br>          ls -R ./cypress/videos/ || true<br>          find ./cypress/videos/ -name &quot;*.mp4&quot; -exec cp {} ./public/${{ matrix.browser }}/videos/ \;<br><br>          echo &quot;Content of ./public/videos after copy&quot;<br>          ls -R ./public/${{ matrix.browser }}/videos || true<br><br>          cp -r ./cypress/screenshots/* ./public/${{ matrix.browser }}/screenshots/ || true<br>          cp -r ./cypress/reports/mochawesome/* ./public/${{ matrix.browser }}/ || true<br>          cp -r ./cypress/mochawesome-report/* ./public/${{ matrix.browser }}/mochawesome-report/ || true</pre><p>The purpose of the <strong>Copy artifacts</strong> job is to locate the <strong>videos</strong> and <strong>reports.json</strong> files generated by Cypress and move them into separate folders. This helps keep everything <strong>organized</strong> before the final deployment to gh-pages.</p><p>This step was a bit tricky to set up because we’re dealing with Cypress test results, which produce <strong>two different artifacts</strong>: one for <strong>Chrome</strong> and another for <strong>Edge</strong>. To address this, I had to come up with a solution to <strong>iterate over each artifact</strong>. This is why I included these parameters in the middle of the path, like so:</p><pre>./public/${{ matrix.browser }}/videos</pre><p>By using this dynamic path structure, we ensure that the results for each browser are properly placed in their respective folders.</p><pre>- name: Generate Index Page<br>        run: |<br>          mkdir -p ./public<br>          node generate-index.js</pre><p>This step is crucial because, at the end of the pipeline, we’ll have <strong>two separate </strong><strong>report.html files</strong> generated: one for <strong>Chrome</strong> and one for <strong>Edge</strong>. To keep things simple and organized, I’ve created a <strong>single </strong><strong>index.html</strong> page that contains links redirecting to both reports.</p><p>The file <strong>generate-index.js</strong> is located in the root folder of the project (feel free to check the code there). The primary purpose of this script is to generate the <strong>index.html</strong> file. This new file will then be deployed to the gh-pages branch, along with the <strong>videos</strong> and <strong>reports.json</strong>.</p><p>And finally the last step is to publish everything into GitHub Pages:</p><pre>- name: Deploy to GitHub Pages<br>        uses: peaceiris/actions-gh-pages@v3<br>        with:<br>          github_token: ${{ secrets.GITHUB_TOKEN }}<br>          publish_dir: ./public<br>          keep_files: true<br>          user_name: &#39;github-actions[bot]&#39;<br>          user_email: &#39;github-actions[bot]@users.noreply.github.com&#39;</pre><p>For that I’m using <a href="https://github.com/marketplace/actions/github-pages-action">special GitHub Action</a>. It requires couple of arguments, like github_token (which will be read by workflow from the env variable) and directory where static page is located.</p><p>I’ve also added two optional arguments — user_name &amp; user_email because this step will be creating a new commit on every page deployment. By default this user would be me (even if a workflow is doing it), therefore for clarity, I’ve change it to github-actions[bot] .</p><p>And the last thing which we need to do is to create gh-pages branch on <em>GitHub</em> and check if <em>GitHub Pages</em> feature is enable for your project.</p><p>The latter can be found on<em> GitHub</em>, on a project site in <strong>Setting</strong> -&gt;<strong> Options.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*HlRB0aZHM3kCn6gY.png" /></figure><p>There is there a <strong>GitHub Pages</strong> section in which you need to make sure that a <strong>Source</strong> is set up to the <strong>gh-pages</strong> branch.</p><p>At last, we can check if everything is set up correctly. To do that just commit all the changes and push to GitHub, which will trigger the action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lA6oYXQpjgnCs0qyuWr9gA.png" /></figure><p>Great! Enter a report page, you’ve just deployed. It will be available on address: <a href="https://clark-ewerton.github.io/cypress-serverest-cicd/">https://clark-ewerton.github.io/cypress-serverest-cicd/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zCe_BQJMPQAY7kb4Ezgegg.gif" /></figure><p>And that’s it! I hope you’ve enjoyed this entry and it will help you automate your E2E tests. I’m opened to suggestions as well 😉</p><p>As usual, here is the source code for mentioned project:</p><p><a href="https://github.com/clark-ewerton/cypress-serverest-cicd">GitHub - clark-ewerton/cypress-serverest-cicd: Project to demonstrate knowledge in Cypress + Design Patterns + CI/CD (Github Actions and Pages) + Mochawesome Reports + Multiple Browsers</a></p><blockquote>This side project helped me break the routine and reminded me why I love QA. If you’re stuck in the same loop, maybe it’s time to grab your own coffee and build something cool.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Z-7OGXZiaYY8vjuY" /><figcaption>Photo by <a href="https://unsplash.com/@cristofer?utm_source=medium&amp;utm_medium=referral">Cristofer Maximilian</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cf10840f47c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to automate XML request/response testing in SOAPUI using the SOAPUI Maven library, Java, JUnit…]]></title>
            <link>https://medium.com/@clarkewertonSilva/how-to-automate-a-testing-soapuis-xml-request-response-using-soapui-s-maven-library-java-junit-605a40281b50?source=rss-48c6ffd6a8fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/605a40281b50</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[soapui]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[testing-framework]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Clark Ewerton]]></dc:creator>
            <pubDate>Sun, 17 Apr 2022 01:48:45 GMT</pubDate>
            <atom:updated>2025-04-14T00:12:25.496Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to automate XML request/response testing in SOAPUI using the SOAPUI Maven library, Java, JUnit, and Cucumber?</h3><p><em>In this article, I will help you guys tackle a problem that I faced in my first year as a Software QA Engineer at an IT company.</em></p><p><em>Basically, I used to work as a Software QA Engineer in a squad specialized in creating SOAP WebServices for the company. As a QA, I not only had to test these manually but also come up with a solution to automate them from scratch.</em></p><p><em>Initially, I thought about using the SOAPUI program itself, since you can create TestSuites and TestCases within the tool’s interface. But all of a sudden, I realized that maintaining that structure over time would become extremely expensive as the number of TestCases kept growing. Besides that, SOAPUI’s interface is just awful!</em></p><p><em>So, I had to think outside the box, and then the light bulb went off: using the </em><strong><em>SOAPUI Maven library! </em></strong><em>That was a genius idea because I could create all those automated TestCases directly in a programming language (in this case, Java). Not only that, but I could also use other tools to support the project, like JUnit, Cucumber, and a reporting plugin to generate results, just like we do with modern web/API REST automation projects.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3Z-xXy5bjlHfWHtx" /><figcaption>Photo by <a href="https://unsplash.com/@douglasamarelo?utm_source=medium&amp;utm_medium=referral">Douglas Lopes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>How it works?</h3><p>Basically, what we are going to do is create a way to automate the simple flow of making a request in the SOAPUI program as well as receiving a response, e.g.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DClRSqvHrr9KEHmc.png" /></figure><p><strong>Note: </strong>here the aim is to focus on automating XML requests as if they were JSON requests. In this case, I’d rather use the RestAssured library for the examples than SOAPUI</p><p>I’m using a public WebService called ‘NumberConversion’, link’s here: <a href="https://www.dataaccess.com/webservicesserver/NumberConversion.wso?wsdl">https://www.dataaccess.com/webservicesserver/NumberConversion.wso?wsdl</a></p><ul><li><strong>First Step: </strong>Create a template for the XML body request in the SOAPUI program.</li></ul><p>First of all, we must have SOAPUI program installed in our machine. The endpoint that I’m using as example is the <strong>“NumberToDollars”</strong> one.</p><p>After that, you import the URL above to the program and create a <strong>TestSuite. </strong>You can give whatever name you want for it<strong>. </strong>After that you are going to create a<strong> TestCase </strong>within it and then, finally, add the request of “NumberToDollars” within that <strong>TestCase. </strong>The structure are gonna to be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MNgt13zi6nzXTH91nd-NHA.png" /></figure><p>So, as you can see, the TestSuite, TestCase, and the request are listed one below the other in this order.</p><p>Now we are going to create the <strong>template itself</strong>, when we say template is nothing more than you add a <strong>‘${}’</strong> inside each tag that we want to fill in XML’s body request. So in this example, we can see that the request has only one field (tag) to fill which is <strong>&lt;web:dbNum&gt;</strong>. So, with the template created, we’ll have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*tPbP3mMY5XiNKdrTElf8xg.png" /></figure><p>Once the template is created, let’s save the project.</p><ul><li><strong>Second step</strong>: Understanding the automated testing framework project.</li></ul><p>First of all, we’ll need to import the two main libraries that allow us to make the magic happen. The first one is the SOAPUI Maven integration itself, so basically, make sure that these two are in the POM.xml:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*Zg7s06pHRlB93Aa-jPEdbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/447/1*wHlSOJo4kbukqfgCk4Dirg.png" /></figure><p>Another important library too is XML Path from RestAssured:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*t74Evm6HIjDIIyW6HkKe_w.png" /></figure><p>Now I show you how this framework was created, here is the full structure of this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m95g6w4YsvzHG_ftcI_xNA.png" /></figure><p>So, basically, we have the <strong>‘core’</strong> package where all the core logic to apply the <strong>abstract factory design pattern</strong> is made. Then, we have three classes here:</p><ul><li><strong>Endpoint </strong>= an interface class containing all the core methods to automate any endpoint of a Web Service.</li><li><strong>EndpointFactory</strong> = class that use the <strong>Abstract Factory design pattern</strong> in order to make ease the process to create instances of an endpoint.</li><li><strong>BaseEndpoint</strong> = class that implements the first two methods of <strong>Endpoint class’s interface</strong>: getProject() and prepareTestCase(). So the endpoint class only extends this one. This will be explained better in the following sections.</li></ul><p>Then we have the <strong>‘responseBody’</strong> <strong>package</strong> where it gives us a structure to make ease the process to assert the response body at the end of our tests using <strong>XML Path (RestAssured library).</strong></p><p>Now, in <strong>src/test/java</strong>, we have the main package <strong>‘numberConversion’ </strong>that represents the WebService that we are using and within it, <strong>5 pattern packages:</strong></p><ul><li><strong>builders</strong></li></ul><p>Here we have a class that implements the <strong>Builder Pattern</strong> to populate our body’s request template:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*tPbP3mMY5XiNKdrTElf8xg.png" /></figure><p>So basically the code using <strong>Builder Pattern</strong> would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*s0bKWjyPFpJutuy0vhiZ6g.png" /></figure><ul><li><strong>endpoints</strong></li></ul><p>Classes that are going to be implemented at this package, always <strong>implements</strong> the <strong>Endpoint </strong>class interface located in <strong>src/main/java/core/Endpoint.java.</strong></p><p>This helps because in order to automate any kind of endpoint, the structure to do so remains the same for all of them which is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*P0uYhAiO45LgVTZysn_Leg.png" /></figure><ul><li>getProject()</li></ul><p>The aim of this method is to bring into code that <strong>template</strong> along with <strong>TestSuite and TestCase</strong> that we create at the beginning of this article in SOAPUI’s project. The project’s file itself is saved on <strong>src/test/resources/soapui/</strong> directory.</p><p>Let’s take a look in this example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*NanivqK0XZ0y3YKN9vnM0A.png" /></figure><ul><li>prepareRequest()</li></ul><p>The aim of this method is to merely calls the TestCase that we created in SOAPUI’s program:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*WMHdUPOgIdfqVBAP_9eozQ.png" /></figure><p><strong>Note:</strong> These two first methods are already implemented by the class <strong>‘BaseEnpoint’</strong> which is located in<strong> src/main/java/core</strong>. So the only thing that I do here is to <strong>extend</strong> this class in order to do that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*wIHY49wrZWOYUfzNbFN4gg.png" /></figure><ul><li>sendRequest()</li></ul><p>Here the aim is to send effectively the request with the template filled using the <strong>BuilderPattern</strong> to build the request’s body:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*xev44s65cbv7GUOdHIyIcQ.png" /></figure><ul><li>validateStatusCode()</li></ul><p>It’ll only verify if the status request was success through a method used in SOAPUI’s Maven library:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*cTf_w-JDvwMOaotwNhaxVg.png" /></figure><ul><li>validateResponseBody()</li></ul><p>And lastly and most important is to validate our test at the end confirming the response body returned from the Service. Basically we wanna see if there was an error, success or warning. To do so, I’m using a library called <strong>XML Path library </strong>from RestAssured that help us going through the response body tree.</p><p>For this, I use the class <strong>‘ResultHandlerWebServices’ </strong>that already contains the structure to make easy the validation itself. So that a look of this implementation:</p><p>First, the <strong>ResultHandlerWebServices</strong> class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*wfBQjKMdEw67ccoOwGrBYA.png" /></figure><p>Then we call this ResultHandlerWebServices into our <strong>validateResponseBody</strong> method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*iDXLrGomEqHdo3weiG9HJg.png" /></figure><ul><li><strong>features</strong></li></ul><p>It needs no introduction. Basically, here I’m going to create a Cucumber file that writes all the test scenarios for that endpoint/web service using Gherkin. Here, I use the concept of examples a lot because each of them is going to represent a specific data scenario, which could be success, error, warning scenarios, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*_8xRwMypoi5FYL2nWABt9w.png" /></figure><ul><li><strong>runner</strong></li></ul><p>The class that will <strong>trigger</strong> all the automated testing process. Basically it will call the <strong>feature/steps classes</strong> in order to start the execution. It uses Junit library but could use TestNG as well.</p><ul><li><strong>steps</strong></li></ul><p>A package that contains the <strong>stepMethods</strong> of Cucumber’s feature.</p><p>The step’s class is the one who are gonna call the ‘EndpointFactory’ class, take a look on how it works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*u_TBNyXtHFTH0eaYnDGJzg.png" /></figure><p>If you liked this article and want to have a better understanding of the whole project itself, please follow the link on GitHub, download it to your IDE, and give it a try: <a href="https://github.com/clark-ewerton/webservice-soapui-xml-java-junit-cucumber-automated-testing">https://github.com/clark-ewerton/webservice-soapui-xml-java-junit-cucumber-automated-testing</a></p><p>Thank you very much!!! Cheers ;D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=605a40281b50" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>