Posts

Showing posts with the label JAVA

Verify a Key exists in a Hashmap

Image
  In a very vast or old Automation suites project, where we have more than 10,000 lines of code and about 1000's test cases. For a new joiner into such projects, ould really find it difficult to understand the existing methods and whether to write new methods for new things or to accommodate into the existing ones only.  Thus, in such cumbersome situations where one feels that a functional method needs to be revamped by the addition of a parameter or a special conditional statement, but doing so may give a massive amount of errors in the entire suite. So instead of adding an additional parameter one way I thought of great help was the use of HashMaps. So let's first understand the concept and working of a HashMap in Java. What is HashMap? Hash table based implementation of the  Map  interface. This implementation provides all of the optional map operations and permits  null  values and the  null  key. (The  HashMap  class is roughly equi...

Read Mails In Java

Image
  There may arise a case in Test Automation where you need to read an OTP from a Mail inbox or would like to access a URL link provided to you in your registered email account. One easy way to do so would be to directly login to the Mail Account on your Browser and perform Actions to read/write data from the webpage. This could sound easy at first but may get complicated when you tend to create locators to uniquely identify elements on these third-party applications which may even get change dynamically. But how about if you can directly get to access the Gmail account by using a simple Java library and writing a few lines of code to get through the content in your mailbox. Today we are going to discuss the same, in which we can easily read the Mail subject + body content without directly logging into the application but by doing so through the backend. Prerequisite Step : The account you are trying to log in must have the Setting  "Less secure app access" enabled, which allo...