Skip to main content

Posts

TestProject smart and powerful recorder

  TestProject already had a smart recorder that was capable of doing fantastic stuff we look for in any record and playback. It can easily generate source code from recorded tests, suggest useful add-ons, allow us to choose from various locator strategies, and view all available properties of any UI components, etc. But have you checked their new versatile and much powerful recorder? You should check it when you get the time and share your feedback. Here are the few enhancements I noticed: 1) Added support for iFrames. I am sure this will be helpful in testing apps that play with so many iFrames. 2) Self-healing feature for the stability of the locators: I have used other tools/frameworks like Canopy(F# library built on top of Selenium) and it wasn't that effective in terms of Self-healing feature but I must say that it works very effectively when I tried using TestProject recorder to record, edit and playback. Also, if a Self-Healing mechanism was used to recover from an error, it...

What all attributes should be there in your automation solution to be called a good solution?

Your automation project should have all of these to be called a good solution : Well drafted Project Design Clear Project Structure and Documentation Defined Page Objects (For UI project) Independent Automated Unit Tests Automated End to End Tests  (Loosely coupled) Reliable Locators (For UI project) Highly effective strategies for managing test data Comprehensive Dependency Management Precise and concise logging and Reporting

Jenkins: Purge Job History Plugin

Download and install: https://github.com/jenkinsci/purge-job-history-plugin This plugin provides the ability to purge all the build records of a job either via a CLI command or via the UI. When this plugin is installed it adds a new action to all Jobs with builds. You can either use UI as shown here (https://github.com/jenkinsci/purge-job-history-plugin) to purge any/all of the following:  Job Pipeline MultiBranch Job (Recursive Flag is Needed) Jobs under a Folder (Recursive Flag is Needed) All Job under Jenkins Instance (Recursive Flag is Needed) Or you can do it via Command line using this command: java -jar jenkins-cli.jar -s http://localhost:8080/jenkins purge-job-history <JobName> -r JobName : Name of the Job whose history you would like to purge r : To reset the next build number to 1 Note* you need super access to perform it.

Find “Cursor” position or currently focused element in a web page with Selenium

Problem Statement: On your registration page, you entered valid values in few mandatory fields but submit the form with no values in few of the mandatory fields. Now along with the error message(s), you want to verify that your cursor position is in the correct field (current focused element) like in the first blank mandatory field using Selenium. Solution : There are many ways to validate that but the simplest one would be to use:> driver.switchTo().activeElement() Use : Switches to the element that currently has focus within the document currently "switched to", or the body element if this cannot be detected. This matches the semantics of calling " document.activeElement " in JavaScript. Returns : The Web Element with focus, or the body element if no element with focus can be detected. And then you can put assertion based on your expected focused element, something like: Assert.assertTrue(driver.findElement(By.xpath("//input[@type='password']...

How to Unzip files in Selenium (Java)?

1) Using Java (Lengthy way) : Create a utility and use it:>> import java.io.BufferedOutputStream; import org.openqa.selenium.io.Zip; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream;   public class UnzipUtil {     private static final int BUFFER_SIZE = 4096;     public void unzip (String zipFilePath, String destDirectory) throws IOException {         File destDir = new File(destDirectory);         if (!destDir.exists()) {             destDir.mkdir();         }         ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));         ZipEntry entry = zipIn.getNextEntry();         // to iterates over entries in the zip folder         while (en...

Locate disappearing elements

You don't have access to the source code and want to inspect elements like HTML5 validation error messages, Wait icon, dynamic search list, or for that matter any disappearing element in your browser that disappears when your mouse moves away?  There are many ways to do that but using below we should be able to capture most of those kinds of disappearing elements/scenarios: Open Chrome Go to that page where you would like to inspect the disappearing element Open dev tools (F12) Select the "Sources" tab While the element you want is displayed, press F8. This should halt the script execution by freezing the DOM (Paused in debugger mode) As the DOM is in the frozen state, now we should be able to hover/select that element to inspect that. #smallAndOldTip #TipsAndTricks #testAutomation #devTools

Where should we keep sensitive information in automation projects?

Of course, nothing can beat encryption/decryption to safeguard our sensitive data but here is one more approach to store your project data and retrieve. Environment Variables are key/value pairs like Properties. We can use this to allow config (sensitive) information to be passed into applications. We can use it in any automation project, not necessarily for Selenium only. Like every approach this too has it’s own pros and cons but for sure, it’s better than keeping your sensitive date in code directly or in a property file. Good read by Alex — https://medium.com/@alexsiminiuc/in-selenium-projects-keep-sensitive-information-in-environment-variables-3c9eb6521080