Skip to main content

Posts

Showing posts with the label Java

Use curl in java without third party libraries

curl is a command line tool which is used to transfer data to and from server. For example, following command can be used to get oAuth token using curl command - curl -u user:’password https://token.auth.xxx.com/ o/p - xxxxaaf9-zzzz-4be7-xyz6-xxxxxxxxxx Here is the example of executing curl from java without using any third party library - import java.io.BufferedReader ; import java.io.IOException ; import java.io.InputStream ; import java.io.InputStreamReader ; import java.net.URL ; import java.net.URLConnection ; public class CurlTest { public static void main ( final String [] args ) throws IOException { URL url = new URL ( " https://token.xxx.com/ " ) ; URLConnection uc = url. openConnection () ; String userPass = "tarun" + ":" + "xxx" ; String basicAuth = "Basic " + javax. xml . bind . DatatypeConverter . printBase64Binary ( userPass. getBytes ()) ; uc. setR...

Java Training Tutorials for Software Testing Engineers

UPDATES: Java training tutorial with flavor of Selenium Webdriver are live now :) The boundaries between software testing and development are beginning to blur in today’s technological environment. Knowledge of programming language would not just help you gain more knowledge in the field of software testing but also makes you more competitive in today’s job market. When I started with Selenium Training Tutorial, I assumed that every one is from programming background. Many of you have asked me that it is very difficult for you to learn Selenium without knowledge of a programming language. Hence I decided to create video tutorial in java, especially designed for software test engineers. Those software test engineers who have little or no programming experience. Learning one programming language would almost always make it easy for you to learn any other language. But there is  one condition  :) I would begin with java training tutorials when Software Testing forum ...

Beginner to Selenium Java Library, How much java to learn?

You have decided to learn Selenium to automate your web application. But not sure where to begin from. There is already one awesome document available on SeleniumHQ to learn Selenium. But what if you have least or no programming experience. And if you are going to use java client driver of Selenium then how much java knowledge you need? Herein I have jotted down some java essentials which are needed in order to used java client library of Selenium. OOPS - Encapsulation, Abstraction, Inheritance, Polymorphism.    Needless to emphasize on their importance in programming. Introduction to Class, instance variable, instance methods, class variable, class method, Object Constructor, Abstract Class, Interface, method overloading, method overriding, Package You definitely need to know when to create a class or interface, how to initialize your instance variables, create methods for test scenarios and bundle your test classes in packages C...

Generating Dates in java

This is a small posts which helps in generating custom dates in java. It would be helpful in data generation in Selenium. package com.core; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; public class DateClass { private static String currentDate; private static String futureDate; public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy hh:mm"); Calendar cal = new GregorianCalendar(); currentDate = sdf.format(cal.getTime()); // Current date System.out.println(cal.getTime()); // Formatted current date System.out.println("Formatted Date is: " +currentDate); cal.add(Calendar.DATE, 1); futureDate = sdf.format(cal.getTime()); // Formatted future Date System.out.println("Future Date is: " +futureDate); } }