Posts

Date & Time Handling In JAVA

Image
While automating any web application, there might arise a situation where you might need to play around with Date and Time objects and manipulate them as per your need. Also, you may land into a situation where you need to pick dates from the UI. There are ample situations where I have used Date in all different kinds of projects. So let us understand how to achieve this in Java. Java provides an inbuilt Date  class available under the java.util  package, this class holds the current date and time. Also, there are other classes using which we can simply use the date. First, let's see some methods to get the current date and time in Java. Following is a snippet showing three different ways to get Date/Time in Java, which can further be used to do some other action. Following is the output based on Line Number from the above code. As per the required pattern of date+time format, we can print the date into our console or save them in a variable. Line No. 23/24 shows the easiest ...

Parameterize job in Jenkins

Image
Hi All, In today's blog, we are going to see How to Parameterize our jobs in Jenkins for performing multiple kinds of actions from a single job. So simply starting with the need for this. There may arise a case where you are passing the Credentials and environment from outside the code by means of a CSV file saved in Amazon S3 or you have different TestNG configuration files with different data set and wish to choose one among those. In all these cases the Jenkins job needs to know and forward the same information to the executable. So this can be achieved by using the inbuilt feature of the Parameterization of Jenkins .  So let's start with this. For this, you first simply need to create a New Item from the Jenkins Dashboard, which is actually a new project for you. As soon as you name the Item and click on Save , you will land on the Configuration page of the new Item. Click on the This project is parameterized checkbox. You may now see a dropdown with different options to ...

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

Joins in SQL

Image
A JOIN clause in SQL is used to combine the records/rows from two or more tables, based on a common column that is present in the two tables. It creates a set that can be saved as a table or used as it is. They are predominantly used when a user is trying to extract data from tables that have one-to-many or many-to-many relationships between them. Following are the types of SQL Joins:   1.  Inner Join The Inner Join in SQL keyword selects all the common rows from each the tables which satisfies the given condition.                                                                2.  Left Join This Left Join returns all the rows from the left table (Table 1) and the matched records from the right table (Table 2). The result is NULL from the right side table if there is no match in Table 2....