In this article you will have access to a huge number of reusable functions for test automation in java with examples. This can be considered as your bible for all of your needs.
We will divide them in to multiple categories as below
- String manipulation
- Date and time
- Number manipulation
- Currency related
Remember that you can customize all the functions written in this article for your own needs. One of our assumption is that we are writing all the methods in a class by name “CM”. The methods have static scope, which allows you to call the methods without creating an object.
String manipulation functions for test automation in java
1. Iterate through all pattern matches in a string and replace with a given string | ||||
---|---|---|---|---|
Purpose: This method is generally used when we want to replace a certain pattern of words in a string with different string or value. You can customize this code to your needs.
Code:
|
Date & Time functions for test automation in java
1. Function to get current date in a specific format | ||||
---|---|---|---|---|
Purpose: Generally in a test case you might want to enter today’s date in an input field. You can get date using below method.
Code:
|
Founder of TestingTools.co, constantly shares knowledge on different test automation tools. Has experience in building proof of concepts, solutions, frameworks, platforms & implementation of test automation projects.
In pursuit of building a platform with inbuilt framework and reusable components for Oracle Cloud applications ( Oracle HCM, CX, SCM, Financials clouds, Salesforce and other cloud applications )
Major accomplishments in his career:
Product architect and development manager for test automation platforms
Oracle Flow Builder @ Oracle
CloudTestr @ Suneratech
2 times to oracle open world
More than 20 successful POCs ( Proof of concepts )
100 demos
Designed pricing models.
Trained more than 50 members.
Built more than 100 re-usable functions.
Worked with tools:
OATS – Oracle applications testing suite
Selenium + Java / C#
Protractor
NightwatchJS
CodedUI
PyWinAuto