How to trigger a workflow from another workflow using GitHub Action

How to trigger a workflow from another workflow using GitHub Action

GitHub Actions has revolutionized the way developers and testers automate their workflows. With Actions, developers can easily define and customize their CI/CD processes, enhancing productivity and code quality. One of the powerful features of GitHub Actions is the ability to trigger workflows from another workflow GitHub Actions. In this article, we will delve into the intricacies of mastering GitHub Actions and explore how to trigger workflows from other workflows.

GitHub Actions is a powerful automation framework integrated into GitHub. It allows developers and testers to define custom workflows composed of one or more jobs, each consisting of various steps. These workflows can be triggered based on events such as push and pull requests, commits, or scheduled actions. The benefits of using GitHub Actions include faster development cycles, improved collaboration, and streamlined release processes.

Before we delve into triggering workflows, let’s define what a workflow is in GitHub Actions. A workflow is a configurable automated process that runs on GitHub repositories. It consists of one or more jobs, each defining a set of steps. These steps can perform tasks such as building, testing, and deploying code. 

It is important to understand workflow dependencies to trigger a workflow from another workflow. Workflow dependencies refer to the relationships between different workflows, where one workflow triggers the execution of another workflow. By leveraging workflow dependencies, developers and testers can create a seamless and interconnected automation pipeline. 

In complex development scenarios, there is often a need to trigger workflows based on the completion of other workflows. This can be particularly useful when different parts of the development process depend on each other and when different teams collaborate on a project. By triggering workflows from related workflows, developers and testers can automate the execution of dependent tasks, ensuring a smoother development workflow. 

The advantages of workflow interdependency are numerous. Firstly, it allows for a modular and reusable approach to workflow automation. Instead of duplicating steps across different workflows, developers, and testers can encapsulate common operations in one workflow and trigger it from others. This promotes code reusability, reduces maintenance efforts, and enhances overall development efficiency. Moreover, workflow interdependency enables better collaboration between teams working on different aspects of a project, ensuring a seamless integration between their workflows. 

  • A GitHub repository having a workflow defined in it (repository_01)
  • Another GitHub repository (repository_02) has a workflow defined in it that triggers after repository_01 workflow completion.
  • GitHub personal access token 

As we have all the required stuff for our goal then let’s get it done. First will understand about GitHub personal access token.

Personal access tokens are an alternative to using passwords to authenticate GitHub when using the GitHub API or the command line. Personal access tokens are intended to access GitHub resources on your behalf.

To learn more about GitHub personal access tokens visit the official website of GitHub https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

1: First, Access your GitHub account by logging in.

2: Navigate to your profile, click on “Settings,” and proceed to “Developers.”

3: Click on Personal Access Token and then Select Token Classic.

4: Navigate to and choose “Generate new token,” then select Generate new token Classic.

5: Here, we Include a note for your Access Token (PAT) – it’s optional. Choose the expiration date for your PAT. Select the scope and at last click on generate token. Copy the token and paste it on a notepad. 

(Remember the selected scope will decide the permissions and authorization to access another repository and workflow)

So now we need to add the generated PAT to our repository_01 as a secret to do this follow the below steps.

  • To navigate to your repository, you can click on the settings.
  • Then go to secrets and variables then select the Action button.

Select the repository secret, add PAT_TOKEN in the name, and paste the copied personal access token in the value. Click on Add Secret.

To create a workflow head over to the action tab and click on new workflow. Then select Set up workflow yourself. Now customize your workflow and add the below step to trigger the (repository_02) workflow.

Let’s understand the trigger-workflow02 stage. Following is the secret we have added is used here to provide the permissions and the authorization to understand and trigger the workflow_02 of repository_02 also replace the username with your GitHub username and repository_02 name with your other repository name. 

As our first workflow is ready now let’s create our second workflow for repository_02. Follow the same steps described in the above step for the creation of a workflow. 

Now let’s understand what to consider here, first the triggering event is set as repository_dispatch means when the other repository is completed this workflow will get triggered and now to specify which repository we arousing types as trigger-workflow02 which is defined as a stage in the workflow01

We are done this is how we can trigger the workflow02 of repository_02 when the execution of workflow01 of repository_01 is completed and the status is passed. Below are the output screenshots give it a check.

Till this point whatever we have seen it’s for our personal GitHub account and if we want to implement this concept for the organization’s GitHub account then we need to introduce a small change in the workflow01 of the repository_01.

Let’s understand the trigger-workflow02 stage. The secret we have added is used here to provide the permissions and authorization to trigger the workflow_02 of repository_02 also replace the organization with your organization’s GitHub name and repository_02 name with your other repository name. 

In this blog, we have explored the powerful feature of trigger workflow from another workflow using GitHub Actions. By understanding workflow dependencies, leveraging workflow events and triggers, implementing remote triggers, and building scalable workflow chains, developers can enhance their CI/CD processes and workflow automation. To summarize, triggering workflows from another workflow allows for increased reusability, collaboration, and customization of automation processes. By embracing these features, developers can optimize their development workflows and empower their teams to achieve greater productivity and efficiency.

Test Automation using Cucumber, JavaScript, and Webdriver.IO

Test Automation using Cucumber, JavaScript, and Webdriver.IO

Introduction:

In this blog, we have created the WebdriverIO framework, which will help to run test cases on web applications on different browsers. WebdriverIO is a popular open-source test automation framework for Node.js.Creating a test automation framework using Cucumber, JavaScript, and WebdriverIO offers several benefits that can streamline your testing process and improve the efficiency and maintainability of your automated tests. Here’s why you might want to consider using this combination:

1. BDD Approach with Cucumber:

Cucumber enables Behavior-Driven Development (BDD), allowing you to write test scenarios in a human-readable format.

2. JavaScript Language:

JavaScript is a widely used programming language for web development, making it accessible to many developers.

3. WebdriverIO as Test Automation Framework:

WebdriverIO is a popular JavaScript-based WebDriver framework that simplifies interactions with browsers and elements on web pages. It also provides a variety of built-in commands for browser automation, making test script development more efficient.WebdriverIO supports multiple testing frameworks, including Mocha and Jasmine, which can be integrated with Cucumber for BDD.

4. Cross-Browser Testing:

With WebdriverIO, you can quickly run your tests across different browsers and browser versions. This ensures that your application functions correctly and consistently across various browser environments.

5. Reusability and Maintainability:

The combination of Cucumber and WebdriverIO promotes the creation of reusable step definitions. Moreover, this modularity makes it easier to maintain test scripts and reduces duplication of code.

6.  Parallel Execution:

WebdriverIO supports parallel test execution, which can significantly reduce the overall test execution time.

7. Community and Support:

Both Cucumber and WebdriverIO have active communities, which means you can find a wealth of resources, tutorials, and plugins to enhance your automation efforts.

Let’s see how webdriverIO works and Its process:

Pre-requisites:

1. Make sure you have Node.js installed on your system. You can download and install it from the official website: https://nodejs.org/en/

2. Open your terminal or command prompt and create a new directory for your WebdriverIO project or else create a folder wherever you want & open it in VSCode

3.  VSCode

Initialize a new npm project by running the following command:  “npm init wdio .” This will create WebdriverIO packages and their installation.

Once you execute that command you will get the following message:

“Need to install the following packages:

  create-wdio@8.2.3

Ok to proceed? (y)”

If you proceed by pressing “y”, you will receive a list of instructions on how to generate the framework. You can follow these instructions to create the desired WebdriverIO framework.

Once you have completed the framework generation process, it will create a package.json file that will serve as a record of your project’s dependencies. This file will help you manage and keep track of the dependencies required for your project.

{
  "dependencies": {
    "@wdio/selenium-standalone-service": "^8.3.2"
  },
  "devDependencies": {
    "@wdio/cli": "^8.3.10",
    "@wdio/cucumber-framework": "^8.3.0",
    "@wdio/local-runner": "^8.3.10",
    "@wdio/spec-reporter": "^8.3.0",
    "chromedriver": "^110.0.0",
    "wdio-chromedriver-service": "^8.1.1"
  },
  "scripts": {
    "wdio": "wdio run ./wdio.conf.js"
  }
}

“Install WebdriverIO and its CLI tool by running the following command:

npm install webdriverio @wdio/cli –save-dev”.

This will install WebdriverIO and its CLI tool as dev dependencies and save them in your package.json file.”

Package-json:

package.json is a file used in Node.js projects that contains metadata and configuration information for the project, as well as a list of dependencies and dependencies required for the project to run. It is located in the root directory of the project and is used by package managers such as npm (Node Package Manager) to install and manage dependencies.

Wdio.conf.js: 

This file contains the configuration settings that define how the test automation framework runs and interacts with the web application being tested. It has Capabilities, Specs, Framework, Reporter, Hooks, Services, etc.

exports.config = {
    runner: 'local',
    specs: [
      './features/**/*.feature'
    ],
    // Patterns to exclude.
    exclude: [
        // 'path/to/excluded/files'
    ],
    maxInstances: 10,
    capabilities: [{
        maxInstances: 5,
        browserName: 'chrome',
        acceptInsecureCerts: true
    }],
acceptInsecureCerts: true   
  }],
    logLevel: 'info',
    bail: 0,
    baseUrl: 'https://www.calculator.net/',
    seleniumLoginUrl: 'https://demo.guru99.com/test/login.html',
    waitforTimeout: 10000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    services: ['chromedriver'],
    framework: 'cucumber',
    reporters: ['spec'],
    seleniumAddress: 'http://localhost:4444/wd/hub',
    cucumberOpts: {
        require: ['./features/step-definitions/*.js'],
        backtrace: false,
        requireModule: [],
        dryRun: false,
        failFast: false,
        snippets: true,
        source: true,
        strict: false,
        tagExpression: '',
        timeout: 60000,
        ignoreUndefinedDefinitions: false
    },
}

So here we have selected the “cucumber” framework which will help create test cases in BDD format. Before we go into framework details, you all should know that all WebdriverIO commands are asynchronous and need to be properly handled using async/await.

The Page Object Model (POM) is a popular design pattern used in software testing to represent web pages as objects and simplify the process of automated testing. The POM structure usually includes a “pageobjects” folder, which contains classes or files that represent individual pages on a website or application. These page object classes or files encapsulate the elements and actions related to a specific page, making writing and maintaining automated tests easier. By using the POM, testers can create a more organized and maintainable framework for their test automation efforts.

1)    Features

2)    Steps

3)    Pages

Features:


This folder contains another two folders, i.e., pageobjects, Step-definitions, and features files. The “feature” folder is typically used in the context of behavior-driven development (BDD) frameworks such as Cucumber, which uses a natural language syntax to describe test scenarios. The “feature” folder houses files that define the scenarios or features to be tested.

To create a feature file in VSCode for implementing behavior-driven development (BDD) scenarios using Cucumber, you can follow these steps:

·       Open VSCode and navigate to the folder where you want to create the feature file.

·       Right-click on the folder, go to “New File”, and click on it to create a new file.

·       Give the file a name with the “.feature” extension, for example, “login.feature”

Feature: Checking calculator functionality 

Scenario: Verify addition on calculator
Given User is on the calculator page
When User taps on "4"
And User taps on operator
And User taps on "5"
Then User verifies the answer as "9"

Scenario Outline: Verify user can perform multiple operation
Given User is on the calculator page
When User clicks on num1 "<number1>"
The user clicks on the "<operator>"
And User clicks on num2 "<number2>"
Then User verifies "<answer>"
Examples:
    | number1 |number2 | operator | answer |
    | 4       | 5      | +        | 9      |
    | 5       | 3      | -        | 2      |
    | 4       | 5      | *        | 20     |
    | 6       | 2      | /        | 3      |

In the above feature file, I have shown one simple scenario where I have performed a simple addition operation, and in the next scenario, I have created a scenario outline where different operations are performed, including addition, subtraction, multiplication, and division.

Step-definitions:

The “step-definitions” folder contains files or classes that define the behavior or actions associated with each step in the BDD scenario.

In WebDriverIO, you can generate step definitions for the given scenarios in a feature file using a tool called “cucumber-boilerplate”.

Following are the steps to generate steps in WebDriverIO using cucumber:

Install the “cucumber-boilerplate” package as a development dependency by running the following command in your project directory: “npm install cucumber-boilerplate –save-dev”

Once the installation is complete, you can generate the step definitions by running the following command: “npx cucumber-boilerplate generate”

This will prompt you to enter the path to the feature file for which you want to generate the steps.

Provide the path to the feature file (e.g., “./features/login.feature”) and press Enter.

The tool will generate the step definitions in JavaScript format, which you can then copy and paste into your WebDriverIO project’s step definition files.

const { Given, When, Then } = require('@wdio/cucumber-framework');
const addPage = require('../pageobjects/AddPage');
Given(/^User is on calculator page$/, async () => {
    await addPage.visitWeb()
  });

When(/^User taps on "(\d+)"$/, async (num) => {
    await addPage.tapNumber(num)
})

When(/^User taps on operator$/, async () => {
    await addPage.tapOperator()
}
Then(/^User verifies answer as "(\d+)"$/, async (ans) => {
    await addPage.getAns(ans)
})

When(/^User clicks on num1 "([^"]*)"$/, async (num1) => {
    await addPage.clickNum1(num1)
})

When(/^User clicks on num2 "([^"]*)"$/, async (num2) => {
    await addPage.clickNum2(num2)
})

When(/^User clicks on the "([^"]*)"$/, async(opt) =>{
   await addPage.clickOperator(opt)
})

Then(/^User verifies "([^"]*)"$/, async(ans) =>{
   await addPage.verifyAnswer(ans);
})

In the above code, you can see we have integrated steps for each line of the feature file, so we can run code in BDD format.

Page objects:

These are classes that represent a web page, containing methods and properties that interact with the page’s elements, such as buttons, links, and input fields.

const { config } = require("../../wdio.conf");
const assert = require('assert');
const addPageLoc = require("../../Locators/AddPageLocators")
const scr = require('../pageobjects/ScreenshotPage')
class AddPage{
    constructor(){
        this.plusOpt = addPageLoc.plusOpt;
        this.answer = addPageLoc.answer;
    }
    // Since we parameterized the value for the locator, we kept it as is.
    getNumber(num){
        return $('[onclick="r('+num+')"]')
    }
    async tapNumber(num){
        await this.getNumber(num).click();
        scr.takeScreenshot('tapping_number');
    }
    async tapOperator(){
        await this.plusOpt.click()
        await browser.pause(3000);
        scr.takeScreenshot('tapping_operator');
    }
    async getAns(){
        let txt = await this.answer.getText()
        console.log("Answer of addition: " +txt);
        scr.takeScreenshot('gettingTextOfElement');
    }

    async visitWeb(){
        await browser.url(config.baseUrl)
        scr.takeScreenshot('webUrl');
    }

    async clickNum1(num1){
        await this.getNumber(num1).click();
        scr.takeScreenshot('clicking_number1');
    }
    async clickNum2(num2){
        await this.getNumber(num2).click();
        scr.takeScreenshot('clicking_number2');
    }
    async clickOperator(opt){
        await $('[onclick="r(\''+opt+'\')"]').click();
        // await this.operator.replace('XXX', opt).click();
        scr.takeScreenshot('clicking_operator');
    }
    async verifyAnswer(ans){
        let result = await this.answer.getText()
        console.log("Retrieving text value from element: " +result)
        assert.equal(result,parseInt(ans));
        scr.takeScreenshot('verifyingResult');
    }
}
module.exports = new AddPage();

The browser.pause() method was used to pause it for the specified amount of time. It takes time in milliseconds.

Also, we added methods to the “AddPage” class, such as click() and setValue(), that are necessary to perform operations on web elements. Also, the setValue() method has been used for sending values for web elements.

Locators:
              This folder includes all the locators required to operate web elements

module.exports = {
    plusOpt: $('[onclick="r(\'+\')"]'),
    answer: $('[id="sciOutPut"]'),
    operator: $('[onclick="r(\'XXX\')"]'
}

In the above code, we listed out all the locators in one file and then imported them into pages, removing clumsiness from the code

Now that we have completed implementing the Page Object Model (POM) design pattern, we can consider incorporating additional functionalities to further enhance the framework’s suitability and reliability.

Screenshots:

To add screenshot functionality to your code, you need to incorporate the following code into your implementation:

class ScreenshotPage{
    takeScreenshot(filename) {
        const timestamp = new Date().getTime();
        const filepath = `./screenshots/${filename}_${timestamp}.png`;
        browser.saveScreenshot(filepath);
      }
}

module.exports = new ScreenshotPage();

Import this code into the page where you need to capture a screenshot by calling takeScreenshot(‘nameOfScreenshot’).

Screenshot
Calcuator.net webdriverio

The above image displays the screenshots it took. The sequence of screenshots offers an overview of the test case, illustrating actions taken at each step.

Cross-Browser Testing:

Cross-browser testing is a practice in software testing that involves testing a web application or website across multiple web browsers and browser versions to ensure its consistent functionality and appearance across different browser environments.

Capabilities:

In the wdio.conf.js file, make changes similar to what I have done in the ‘capabilities’ section. I have attached the following code for your reference. You can use it for assistance and make changes accordingly.

capabilities: [
    {
        browserName: 'chrome',
        acceptInsecureCerts: true
      },
      {
        browserName: 'firefox',
        acceptInsecureCerts: true
     }
],

Services:

In the ‘services’ section of the wdio.conf.js file, make changes similar to what I did in the following code snippets. You can make changes accordingly and run your test cases smoothly.

services: ['selenium-standalone'],
    seleniumInstallArgs: {
        drivers: {
          chrome: { version: 'latest' },
          firefox: { version: 'latest' },
          chromiumedge: { version: 'latest' },
        },
      }
      seleniumArgs: {
        drivers: 
          chrome: { version: 'latest' },
          firefox: { version: 'latest' },
          chromiumedge: { version: 'latest' },
        },
      },

The above code will assist you in implementing different browsers for testing, and you can also add others like Microsoft Edge, Safari, etc.

Allure_Report:

Allure Reports are often preferred over Cucumber Reports due to their visually appealing visualizations, comprehensive insights, step-by-step details, time tracking, integration capabilities, and historical trend analysis.

Once you have completed the automation process, testers need to generate reports to track the status of test cases, including pass or fail results and the exact location of failures. You can use the Allure report functionality for this purpose in your WebDriverIO project Follow these steps to include the Allure report:

1.     Install the Allure Reporter plugin for WebDriverIO using the following command: “npm install @wdio/allure-reporter –save-dev”

2.     Add the Allure Reporter plugin to your wdio.conf.js file as a reporter. Following is an example configuration:

exports.config = {
reporters: ['spec', ['allure', {
outputDir: './allure-results',
disableWebdriverStepsReporting: true,
disableWebdriverScreenshotsReporting: false,
}]],
}

In this example, we’re using the spec reporter for console output and the allure reporter for generating the allure report. The outputDir option specifies the directory where it will generate the report files.

1.     Add the Allure command line tool to your project by running the following command: “npm install allure-commandline –save-dev”

2.     After running your tests, generate the Allure report by running the following command: “npx allure generate allure-results –clean”

Allure Repost webdriverio

Project Folder Structure: 

As we have completed the design of the folder structure for the framework, you can now see below the image of what the framework’s folder structure looks like.

allure Report webdriverio

The image above shows the integration of different folders in the WebdriverIO framework. I have provided explanations for each folder and its contents.

To run test cases on a browser, you can use the following commands:

·       npx wdio wdio.conf.js

·       npx wdio run wdio.conf.js –spec features\Addition.feature // To run a specific feature file

·       npx wdio wdio.conf.js –spec ./path/to/your/test.js –browser chrome // To run on a specific browser”

Note: Please make sure to replace the path and file names with the appropriate ones for your specific setup

Conclusion:

WebdriverIO is a comprehensive and feature-rich framework that empowers developers and testers to create reliable and efficient automation tests for web applications. It is a vast ecosystem of plugins, extensive documentation, and also active community support make it a top choice for automation testing in the modern web development landscape. By adopting WebdriverIO, organizations can significantly improve their web application testing efforts and deliver high-quality software to their end-users.

Read more Blogs here.

How to execute Playwright-Js tests on BrowserStack

How to execute Playwright-Js tests on BrowserStack

        

Introduction:

At times, certain project specifications demand comprehensive testing of a web application across a diverse range of web browsers and their varying versions. Maintaining consistent functionality, visual appearance, and user engagement is essential.

To execute this type of cross-browser testing efficiently, there are two primary approaches:

  • One involves manual testing, where the website is examined across multiple browsers and devices. 
  • The other approach entails leveraging specialized tools and services that replicate distinct browser environments. 

Particularly, BrowserStack stands out as a tool that has garnered considerable attention in this field, thanks to its intuitive user interface.

Executing test cases on BrowserStack is crucial for QA teams to ensure the compatibility, functionality, and performance of websites and applications across a wide range of real browsers and devices. 

It helps identify bugs, responsive design issues, and user experience problems, while also supporting automated testing and real environment testing. 

BrowserStack eliminates the need for local testing infrastructure, reducing costs and enhancing overall testing efficiency.                                                   

So first let’s talk about the Basic Framework where we can automate test cases using the BDD approach to execute tests on a browser on the local machine. 

So for this instead of explaining it from scratch here again, You can explore my blog where I have explained How to create a BDD automation framework using Cucumber in JavaScript and Playwright.

This blog gives you step-by-step guidance on how to Create Feature files, Steps files, Page Files, and various other utilities to make the framework more reusable and robust. So here is the link to this blog: https://shorturl.at/bjuvU

You can also use the below link to access the BDD automation framework using Cucumber in JavaScript: https://github.com/spurqlabs/Playwright_JS_BDD_Framework

Pre-requisite:

To get started with BrowserStack implementation first store your BrowserStack username and access key in the .env file.
To get the username and access key to navigate to your BrowserStack account. Click on Access key dropdown from dashboard and you will be able to see your username and access key.

Here you will be able to see your account details. Copy your Username and Access Key and store it in a .env file as shown below. To execute tests on BrowserStack set the Browserstack variable to ‘true’.

Browserstack = true
BROWSERSTACK_USERNAME='browserstack_usename'
BROWSERSTACK_ACCESS_KEY='browserstack_accessKey'

Now to set BrowserStack configurations Create a file as “Browserstack.js”, as you can see I have created a “Browserstack.js file” in the Utility folder.

Playwright Framework


Here are the essential BrowserStack configurations to integrate into this file.

const cp = require('child_process')
const playwrightClientVersion = cp
    .execSync('npx playwright --version')
    .toString()
    .trim()
    .split(' ')[1]
function caps() {
    return {
        'browser': 'playwright-chromium',
        'os': 'Windows',
        'os_version': '10',
        'browserstack.username': process.env.BROWSERSTACK_USERNAME,
        'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY,
        'client.playwrightVersion': playwrightClientVersion
    }
}
module.exports = { caps }
.execSync('npx playwright --version')
    .toString()
    .trim()
    .split(' ')[1]

.execSync:

The playwrightClientVersion variable is declared and assigned the output of the shell command executed using execSync from the child_process module.

.execSync('npx playwright --version’):

The command executed is npx playwright –version, which retrieves the version of the Playwright framework installed on the system. The output is converted to a string, trimmed to remove leading or trailing whitespace, and then split into an array based on spaces. The second element of the array (split(‘ ‘)[1]) represents the Playwright’s version.

caps():

This function is responsible for generating a configuration object used for browser testing with the BrowserStack platform and Playwright framework. It returns an object that contains configuration options for browser testing like browser, os, os_version, etc.

process.env.BROWSERSTACK_USERNAME, process.env.BROWSERSTACK_ACCESS_KEY:

These are the variables from the .env file. If you are not using a .env file you can directly pass the BrowserStack username and access key.

As we have all the configurations ready, we will set up a test environment to execute tests on BrowserStack. Use the file where you have your Before and After methods. In the playwright-Js Framework we have these methods stored in the ‘TestHooks.js file’ so will update that file as below.

const { Before, AfterAll } = require('@cucumber/cucumber')
const page = require('@playwright/test')
const path = require('path');
const { chromium } = require('playwright')
require('dotenv').config({
  path: path.join(__dirname, '../.env'),
});
Before(async (scenario) => {
  if (process.env.BrowserStack === 'true') {
    try {
      const capabilitiesBr = require('./BrowserStack').caps(scenario)
      global.browser = await chromium.connect({
        wsEndpoint: `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(JSON.stringify(capabilitiesBr))}`,
      })
      viewport = {
        width: 1920,
        height: 900,
      }
    } catch (e) 
      console.error('Error connecting to BrowserStack', e)
    }
  } else {
    global.browser = await page.chromium.launch({ headless: false })
  }
  const context = await browser.newContext()
  global.page = await context.newPage()
})
AfterAll(async () => {
  await global.browser.close()
})

The above code Generates capabilities for BrowserStack using the caps() function from the ‘BrowserStack’ module. Construct the WebSocket endpoint URL for BrowserStack with the generated capabilities.

Now we have completed the BrowserStack implementation in our framework, now you can execute your tests on BrowserStack.

To execute tests on BrowserStack make sure you have “Browserstack = true” in the .env file.

Then you can execute your tests using the command ’npm run test’ on your terminal.

After running the test cases on BrowserStack, you’ll find the report below. Access comprehensive execution videos, and test logs for both successful and unsuccessful cases, along with execution duration.

Conclusion:

Integrating BrowserStack with Playwright JavaScript tests, gives access to a wide range of real browsers and devices, enabling comprehensive cross-browser and cross-platform testing. The scalability and cost-effectiveness of BrowserStack eliminate the need for maintaining an extensive device lab. Ultimately, this integration enhances test coverage, improves software quality, and ensures a seamless user experience across various browsers and platforms.

Read more blogs here

Role of Automated testing in Agile methodology

Role of Automated testing in Agile methodology

What are Agile methodologies?

Agile methodologies are nothing but an approach or practice that applies in Software development and Project management which makes the development process more efficient and helps to maintain the quality of software. It mainly focuses on collaboration, flexibility, and adaptability in the testing process. During development, the software testing practices adhere to the agile methodology.

There are several project management tools such as Kanban, Jira, Scrum, or Extreme Programming (XP).

The core process involved in Agile development:

Define Requirements:

The product owner or analyst along with the development team collaborates with each other and identifies, analyzes, and defines the requirements. User stories are created for specific sprints to define the requirements. And these user stories are collected in the product backlog or product board.

Sprint Planning:

Sprint planning is a process in which a product goal gets defined and a plan for the upcoming sprint is defined. Developers from the development team pick a set of requirements from the product board to work on the upcoming sprint. A Sprint meeting happens and the team identifies the scope of the upcoming sprint and breaks down the requirements into tasks.

Sprint Execution:

In Sprint Execution, the development team starts working on user stories in a time-bound iteration called a Sprint. Daily scrum call meetings are conducted to discuss progress, work, and any impediments during the sprint.

Continuously Integration:

Continuously Integration is a process, where developers make changes in code and those changes are also merged in a remote repository (GitHub) and tested frequently. It automates stages of the project pipeline such as – build, test, and deployment. It helps to team working within agile development.

Agile Testing:

Testing activity occurs in the early phase of the development process. In this phase, the tester collaborates with the developer and PO to understand the requirement and also starts testing the module, and defines the acceptance criteria. Testers start preparing test scenarios and test cases based on user stories. And they execute test cases and report bugs using bug-reporting tools such as Jira.

Incremental Delivery:

In the incremental Delivery phase, a small, developed part of the software is delivered to the customer at the end of each sprint. It helps to improve the quality of software by delivering it in small parts.

Sprint Review:

The Dev team, Pos, and QAs are involved in the Sprint Review meeting. In this phase, Sprint review takes place. Here development team presents work accomplished or gives a demo of whatever they have developed in that sprint. The incomplete issues, backlog adjustments, and Action items are discussed in this meeting.

Sprint Retrospective:

The agenda of this meeting is to examine how Sprint went as far as people, requirements, relationships, processes, and tools.         

Discussions Include:

  • What did we do well?
  • What should we have done better?
  • Identifies area for improvement
  • Suggestions
  • Actions

Let’s talk about Automated Testing:

Automated testing is an Agile practice that allows you to automate test cases through automation tools and execute the test cases to verify the functionality of software applications to meet customer expectations. It is a key aspect of agile development. Automated testing emphasizes manual testing efforts and also provides a way for continuous testing, early bug detection, and quick feedback.

Important aspects of Automated Testing:

  • Test Automation Framework: The team creates an automation framework using specific technology as per requirement and maintains it. It is a structured set of a rule and resources and tools which helps to create, execute, and automated the test cases. It allows us to reuse the code, in test data and also provides a way to generate test results or reports for execution.
  • Continuous Integration: The automation tool makes continuous integration easier when developers make changes in code and those changes are merged in a remote repository (GitHub) and tested frequently. Automated testing is an integral part of this process.
  • Regression Testing: Automated testing plays a vital role in regression testing. It makes sure that there should not be any unintended side effects occurring in the module when new changes have been made. Automation regression tests can be executed fast and repeatedly, giving quick feedback.
  • Continuous Delivery and Deployment: Automated testing allows us to run test suites to ensure that the changes made meet functional expectations and maintain the effectiveness and quality of the product. After completion of the automated testing phase, there is a Continuous Delivery process in which changes are automatically continuously deployed to the staging environment for testing. With this process code, the changes are continuously updated with the latest changes which makes faster delivery of the product in an efficient way.

Benefits of Automated Testing in Agile Methodologies:

  • Faster Feedback: Automated testing provides feedback quickly. It also helps in executing tests, generating results, and finding issues very quickly in the development cycle.
  • Increased Coverage: Automated testing allows you to create a wider range of test scenarios and test cases compared to manual tests.
  • Consistency-It helps to keep consistency in the execution of test cases, reducing human errors. Automated code itself needs to be tested to makes sure consistency and high quality.
  • Time and Cost Efficiency: Automated testing reduces human efforts and it is used in repetitive tasks, so it saves time and resources in the long run.

The working of CI/CD for automation testing in Agile:

CI/CD stands for Continuous Integration and Continuous Delivery as it is a pipeline that helps development teams to automate and makes it more efficient for building code, running tests, and also safely deploying code. The goal of the CI/CD method is to deploy code frequently and deliver working software to customers frequently and quickly.

Usually, Our source code is located on our local workstations. From there, we will commit our source code to the version control system, specifically using Git, which serves as our code management system, and is hosted on GitHub. Once the code is available in the code management system, the CI tool pulls that code automatically and builds under run unit test and then we call it Continuous integration.

During the CI process, we build and compile our source code and generate artifacts. Once these artifacts are generated, we need to deploy them on target env.

Target env may be changed based on the project necessities it may be a staging test, Dev or QA, preview, or production like various env we might have.

Now let’s take the artifacts we want to deploy on a staging environment.

Once it is deployed in the staging env we do the regression test and performance test. Once it successfully passes this test, it can be deployed to the production environment. During the deployment process, after the build, we move it into the staging environment, and if this transition to production can be achieved seamlessly without any manual intervention, we refer to it as Continuous Deployment.

In Continuous deployment, we can automatically deploy into the staging env and production environment.

Benefits of CI/CD:

  • Helps you to build better-quality software.
  • Automate the software release process for making delivery more efficient, rapid, and secure as well.
  • It helps you to automate repetitive tasks.
  • It reduces risks and makes the deployment process more predictable.
  • You can release software more frequently, which helps you to get fast feedback from your clients.
  • It gives a single view across all environments and applications.

What is Test Automation?

Test automation or automation testing is a process of automating test cases using automation tools and frameworks, managing test data, and asserting the automated result with requirements without any manual intervention. Automation testing plays an important role in achieving goals such as faster delivery, continuous integration, and frequent releases.

Benefits of Test Automation in Agile:

  • Faster Feedback: Automated tests can be executed quickly and also provide faster feedback on tests.
  • Improved Test Coverage: Automation tests allow running a large number of test cases across different environments hence it can cover different scenarios in the application.
  • Regression Testing Efficiency: Automation testing is mainly useful for running regression tests so it helps in repetitive testing after each code change.
  • Consistency and Accuracy: As automation testing is done without human intervention, it eliminates the possibility of human errors during test execution.

Benefits of Deployment Automation:

Deployment automation offers numerous benefits for software development, IT operations teams, and the entire organization. Automated deployment is a best practice in agile. Moreover, it allows developers to automate the deployment activities, development process, and testing activities. The following are the key benefits of deployment automation:

  • Faster and More Efficient Deployment: Automated deployment process is faster than manual deployment as it provides quick feedback. So that it reduces the time takes to release the software updates.
  • Consistency: Deployment automation ensures the consistency of the deployment across different environments (staging, dev, preview, production). So that it reduces the risk of configuration errors.
  • Reduce Human Errors: As Manual deployment involves humans which can lead to deployment errors, data loss, or other issues. So here, automation reduces such errors and increases the reliability of the deployment process.
  • Efficient Testing Environment: Automated deployment allows quick provisioning and teardown of the testing environment. This enables development and testing teams to work in isolation and concurrently, leading to faster testing cycles.
  • Cost Savings and Resource Optimization: Automated deployment reduces manual intervention which can lead to saving costs and resources.

Conclusion:

In conclusion, automated testing is an essential part of the dynamic landscape of the agile world. As we’ve explored this blog, it provides faster feedback, consistency, and accuracy, reducing risk and ensuring to delivery of high-quality software. Automation plays an important role in the form of CI/CD that helps you to build better-quality software.

Read more blogs here

Upgrade your Selenium Automation Framework from Java 8 to Java 11

Upgrade your Selenium Automation Framework from Java 8 to Java 11

Introduction:


Starting from September 30th, 2023, Selenium will no longer provide support for Java 8. Instead, the minimum supported version of Java will be Java 11. For the official announcement from Selenium, please refer to this link:

https://shorturl.at/bfiot

Selenium has supported Java for a long period. Java 8 reached the end of active support about a year ago as you can see below the details of version support.

The default of Selenium has not had a major release in several years and also a bug has been found that cannot be fixed. So the decision was made to move to the native Java HTTP client which requires using Java 11 or greater version. So instead of upgrading to the latest Java for now Java 11 will be a cautious step to move forward. In this blog, we will explore how to achieve that with minimal changes.

Download and Install Java 11:

First, you need to download the exe file for the JDK 11 version. For that, you can visit the link provided below:
https://www.oracle.com/in/java/technologies/javase/jdk11-archive-downloads.html
You can get it by signing in to the Oracle which is free. You will have various file types to download. For the exe file, you can refer below image.

After completing the download you proceed with the installation process.

For the installation, you can follow the below steps shown in screenshots. Then the installation process will be completed.

After completing the installation of Java 11.

You will find the file below in your system at the following path: C:\Program Files\Java.

So now you have successfully installed Java 11.

Setting Up Environment variable:

The next step is to set up the environment variable. To do that, simply navigate to the Environment Variable.

Settings > About > Advance System Settings > Environment Variables 

As you can see in the image above, I have successfully updated the JAVA_HOME path with the latest JDK version. Additionally, don’t forget to update the path variable with the latest “bin” folder.

So now start your command prompt by executing the java -version command. You will get to see the latest updated version of Java.

We have now installed Java 11 and configured the Environment Variables.

Update Existing project on the latest installed Java version which is Java 11:

So for now we’ll see how we can update the existing Java 8 project to Java 11

So you must have a pom.xml file present in your existing project framework.

Before:

After:

As you can see the source and target in the above snapshots are version 8. Here you can update the version of the java with latest 11 as we have downloaded and installed Java 11. So after updating the 8 with 11, you have to rebuild the pom.xml project as well. After that, you will see the successfully updated Java version to 11. This is how you need to update your Java version to 11.

Read more blogs here.