Skip to main content

Posts

Showing posts from February, 2022

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/o...