Java: Useful Snippets for Automation Testers


We have a conviction that our day to day work should be a combination of hard and smart work. In automation testing, we can arrive at a solution for a problem in umpteen numbers of ways. However, at times a complex problem might have a simple solution. In this article, we are going to share Java snippets which are much useful for automation testers to do smart work.

Snippet #1-How to check a string contains only numeric value?We can check this criteria using Regex pattern or you can try with Long.parseLong method. However, we recommend you to use Apache Commons Lang3‘s NumberUtils to check whether a string has only numeric.

Snippet #2-How to get Apache POI Numeric Cell value as it appears in Spreadsheet? If you want to get the Numeric value from a cell as it appears in Excel, use the below snippet.

Snippet #3-How to set Network Conditions in Selenium? If you want to run your Selenium script in different network conditions, you can do it using Chrome CommandExecutor as shown below.

Snippet #4-Filtering WebElements using Regular Expression


Leave a Reply

Your email address will not be published. Required fields are marked *