Skip to main content

Posts

Showing posts from 2022

QAOps - Shift in the QA paradigm

QAOps - What is it? Is it a specialization or a new team role? – The answer is No.  QAOps is critical for teams that automate their Continuous Integration and Continuous Delivery (CI/CD) pipelines, as it focuses on speed without sacrificing quality. Head over to our recent blog that explores the various ways to implement. Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

PODAM - lightweight tool to auto-fill Java POJOs with data

 A huge pain for SDETs is filling mock data to our automation test. PODAM is one such library that is easy to use, requires little to nothing set up, and auto-fills Java POJOs with data. It initializes a java object tree with random data, but you can also define a strategy or use attributes to decide the values that should be set (this makes it more powerful than other libraries like Java Faker, JFairy, etc.)   Read more here: https://mtedone.github.io/podam/index.html   Quick nice video: https://youtu.be/oaQSb-PxrrI Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

Pynt - free API security solution

  Pynt is a free API security solution that generates automated security tests based on your existing functional test collection within postman. It appeals to perform dynamic security testing covering all the OWASP API Top 10. More details:  https://www.postman.com/pynt-io/workspace/pynt/overview I tried and it looks promising. #pynt   #postman   #apisecurity   #testing   #security

Selenium 4.6.0 released with Selenium Manager

Implementation of Selenium Manager across bindings is one of the key features of the Selenium 4.6.0 release. The Selenium project wants to simplify how we all set up our environment. Setting up browser drivers has been for many years a task that we need to perform all the time.  To run a Selenium test with Selenium 4.6.0, we only need to have Chrome, Firefox, or Edge installed. If you already have browser drivers installed, this feature will be ignored.  Just add 4.6.0 Selenium dependency: <dependency>     <groupId>org.seleniumhq.selenium</groupId>     <artifactId>selenium-java</artifactId>     <version>4.6.0</version> </dependency> And as is use: WebDriver driver = new ChromeDriver(); Also, future releases of Selenium Manager will eventually even download browsers if necessary. :) Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

Shadow DOM in Selenium 4

To access Shadow DOM elements in Selenium 4 with Chromium browsers (Microsoft Edge and Google Chrome) version 96 or greater, we can use the shadow root method: WebElement  shadowIdContent  = driver.findElement(By.cssSelector("#shadow_host")) .getShadowRoot() .findElement(By.cssSelector("#shadow_content")); What happened in v96 is that Chromium has made its shadow root values compliant with the updated W3C WebDriver specification, which now includes definitions for getting an element’s shadow root and locating elements in a shadow root.   I found this excellent video for the same : https://youtu.be/-uMLqBO2x7c Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

Comparison of maven-surefire-plugin and maven-failsafe-plugin

 Comparison of maven-surefire-plugin and maven-failsafe-plugin: References :     Maven Failsafe Plugin: https://maven.apache.org/surefire/maven-failsafe-plugin/index.html      Maven Surefire Plugin: https://maven.apache.org/surefire/maven-surefire-plugin/index.html   Someone asked me then what is the advantage of using one over the another. The advantage is the way they fail: Failsafe > runs all the integration tests, but if any tests fail during the integration-test phase, the plugin does not fail the build immediately. It still executes the post-integration-test phase. Therefore we can still perform any cleanup and environment tear-down as part of the post-integration-test phase. The subsequent verify phase of the build process reports any test failures. Surefire > It binds with the test phase, in case of any test failures, the build fails, and no further phases execute during the build process.

Publish test results to Microsoft Teams, Slack and many more

  A simple, extendable, and nice alerting tool to forward the test results from your CI/CD environment to different entities like teams or Slack: https://test-results-reporter.github.io/ It publishes test results from test frameworks like JUnit, TestNG, and xUnit.  GitHub link: https://github.com/test-results-reporter/reporter #alerts #automation #reporting #slack #teams #webhooks Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

Want to share Test Results to MS Teams using AdaptiveCards.io?

Steps to follow: Microsoft Teams WebHook: Follow this  https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook to create a webhook. Capture the  URL you will get from Step # 5 from the above article for Posting the Results in MS teams. Select a design from https://adaptivecards.io/samples/ or you can take the one that I created here:  https://github.com/dgambhir01/AdaptiveCards/blob/main/src/main/java/listeners/ResultBuilder.java Now implement the Builder Class and a POJO Class. Sample code:  https://github.com/dgambhir01/AdaptiveCards/blob/main/src/main/java/listeners/CardBodyStructure.java Last but not least add a Listener Class to send Results on Finish. Sample code:  https://github.com/dgambhir01/AdaptiveCards/blob/main/src/main/java/listeners/ResultListener.java Now you can add the above TestNG Listener to your TestNG XML File and run your test cases.  After the Execution, you should see your test results like:

Want to auto retry a failing request in postman based on a set number of max tries and with a certain amount of wait time?

  Of course, there are many ways to tackle it but I have mentioned below one of the ways where you can use the given code in the Tests tab of the postman. Unfortunately, in some of the lower environments, there can be a situation where you request fail at times due to infra issues, timeouts, etc., so in that case, this can be super helpful: var notExpectedText = 'Failed'; var maxTries = 3; var pauseBetweenTries = 5000; if (!pm.environment.get("tries")) {     pm.environment.set("tries", 1); } if ((pm.expect(pm.response.text()).to.not.include(notExpectedText)) && (pm.environment.get("tries") < maxTries)) {      var tries = parseInt(pm.environment.get("tries"), 10);      pm.environment.set("tries", tries + 1);      setTimeout(function() {}, pauseBetweenTries);      postman.setNextRequest('PaymentService'); //here you should give your request name that you want to retry on failure  } else {      pm.environment.uns

How to use Azure DevOps REST API to extract and update data within Azure DevOps?

Azure DevOps offers a fantastic set of REST APIs which allows you to extract and operate data within Azure DevOps by sending an HTTP request to a specific service. It is up to you how you want to call these APIs i.e., using Postman if you are not a fan of coding much or you can use RestAssured, RestSharp libraries if you can write code. I am using Postman here to execute these APIs; all the Azure DevOps Rest APIs expect you to follow these things: 1)    Provide the PAT (Personal Access Token) in the Authorization  tab: o   Type : Basic Auth o   Username : leave it blank o   Password : Enter your PAT Note* Here is how you can create a PAT: https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows#create-personal-access-tokens-to-authenticate-access 2)     Send the request o Select the HTTP Method (Get, Post, Patch, etc.) o Create a request URL, replacing your organization and your project name of yo

assertTrue vs assertEquals for text verification

   We all do text validation in our automation tests to validate whether the returned value is the same as the expected one or not. I see that many folks use the assertTrue command instead of assertEquals to validate the returned text while using assertions from TestNG or JUnit. Let's see why using assertTrue is bad practice for text comparison.   assertEquals public static void assertEquals(String actual, String expected) Asserts that two Strings are equal. If they are not, an AssertionError is thrown. Parameters: actual - the actual value expected - the expected value assertTrue public static void assertTrue(boolean condition) Asserts that a condition is true. If it isn't, an AssertionError is thrown. Parameters: condition - the condition to evaluate   Let’s say that I have an automated test script where I would like to verify the Title of the home page -  we are doing the check using assertTrue as well as assertEquals methods.   String Exp

Want to clear all inputs in a form quickly?

While submitting a form, at times, we get a use case where we need to first clear the default/pre-filled values of all the fields in the form and then enter our desired value. Usually, we do this for every field: WebElement firstName = driver.findElement(By.id("Form_submitForm_FullName")); email.clear(); email.sendKeys("Dheeraj"); Here we are locating an element, and assigning it to a WebElement. After that, we send commands: > clear() to clear the value into the input field  > And then the sendKeys() to fill it in with a new desired value. But isn’t it time-consuming to find all the fields in the form and then clear each field 1 by 1?  Here is the faster alternative… You can send a Javascript command to clear all the fields in one shot : document.getElementById('Form_submitForm').reset() This is just an alternative to reduce some test execution time. You can use any approach that works best for you. Here is the working example: public class Form { W

Properties Files in Java with Owner library

When we create an automation test framework, most of us use properties files to get any configuration like URL, credentials, or whatever data you need to change frequently as a configuration.   In this blog, we will discuss how we can easily manage properties files with the Owner Java library makes properties file management very easy, and minimize the code required to handle application configuration through Java properties files. If you are using Maven, things are quite simple, just add the following section to your pom.xml: <dependencies> <dependency>     <groupId>org.aeonbits.owner</groupId>     <artifactId>owner</artifactId>     <version> 1.0.12 </version> </dependency> </dependencies>   Note * At the time of writing this page, the latest version is 1.0.12, but you need to check if there is any newer version here: https://mvnrepository.com/artifact/org.aeonbits.owner/owner   Suppose your properties file is defined as Conf

Test Data Supplier (TestNG DataProvider wrapper)

  Test Data Supplier (TestNG DataProvider wrapper) If you are a big fan of Stream and Collection API for data manipulation in the modern Java world, give a shot to this library that contains TestNG DataProvider wrapper (as of writing this blog, the latest version is based on TestNG 7.8.0) which helps to supply test data in a more flexible way. Supported return types Collection Map Entry Object[] double[] int[] long[] Stream / StreamEx Tuple A single Object of any common or custom type As it can return StreamEx, it gives you more power to play with flatmap, indices, transposing, etc. You can find more details and sample Gradle/Maven projects on their official GitHub repository page :  https://github.com/sskorol/test-data-supplier Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

Test Automation Fundamentals

 

How to upload a pdf file using REST Assured?

 If you use this code as mentioned in few other blogs and videos:   Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "multipart/form-data"); byte[] fileContent = FileUtils.readFileToByteArray(new File(filePath)); RestAssured.given().headers(headers).body(fileContent).post(url);   There are high chances that you will get errors related to content-type or "400 - Request is not a multipart request". So, the solution is to use: .multiPart("file", new File("/path/to/file"),"application/pdf"). Please note that I have used "application/pdf" as 3rd param in the multiPart method and this value should be passed as per the file type that you are uploading like for the png file it should be "application/octet-stream", for JSON file it should be "application/JSON". multiPart is an overloaded method that can take max 3 parameters:   a)