Menu Bar of the blog

Sunday, 16 November 2014

Module#1: Selenium Overview

What is Selenium?
Selenium is an automation testing tool which works with browsers. It doesn't work with windows based applications.
It works with multiple browsers, like Mozella, Safari, IE, Chrome etc., and across multiple operating systems like Windows, Linux, Solaris, Unix etc. That's the power of this tool as it can work with various browsers and various Operating Systems.
To learn Selenium, it is necessary to learn one of the 6 programming languages. The options are - JAVA, C#, Ruby, Python, Perl and PHP. In this course, we will learn Selenium with JAVA. Implementation of Selenium is independent of the language through which web-site is developed.

Selenium can not be learnt without learning JAVA. So, we will be first going through the basics of JAVA.
Installing JAVA
Step 1: Google - Download JAVA.
Step 2: Click on first link - JAVA.com and download.
To check, if JAVA has been installed or not - Go to Program Files, and check if it contains JAVA folder or not. If it does, then JAVA has been installed successfully.
To write JAVA code, we need an editor. JAVA code can be written in Notepad too. But to handle big projects we need a better editor. We use Eclipse for this purpose.

Downloading Eclipse
Step 1: Google - Download Eclipse.
Step 2: Click on first link and download 'Eclipse IDE for Java EE Developers', depending on your Windows, whether it is 32 or 64 bit.
After downloading, Eclipse comes as a Zip file. On double clicking Eclipse.exe, we get a Workspace Launcher. Through this we can open Eclipse editor and start making Java programs.
Only requirement of Eclipse is to have Java installed.
Below is an Eclipse screen.


Creating First Eclipse Project:-
1. Right Click inside Project Explorer.
2. New -> Project -> Java Project, and enter the Project Name. Project Name should be a logical name without special characters.
3. Choose No, as of now, when asked for JAVA perspective.

The newly created folder in Project Explorer contains src folder and JRE System Library. JRE System Library is basically Java files which got downloaded in the system when Java was installed. And, the files which we will make will go inside src folder.

Creating First JAVA Class:-
1. Right click src folder in Project Explorer.
2. New -> Class -> New Java Class, and enter class name.

On entering Class Name and clicking Ok, following code is displayed.
public class FirstJAVAClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Learning Selenium");
}
}

A .java file is stored in the hard drive in src folder.
Main() - It is the function in which control comes for the first time.
To print something in Java in Console mode, we use the command, System.out.println(). These commands are case-sensitive in Java. Shortcut for System.out.println() is syso and + ctrl + space.
System.out.pintln - prints and moves the cursor to new line.
System.out.print - prints and doesn't move the cursor to the new line.

Why is JAVA important with Selenium?
JAVA is a platform independent language. That is, make a Java program in Windows and deploy it on a UNIX server and it will work, if UNIX server has Java installed. So, it doesn't matter in which platform Java program was built.

Data Types:-
Reserved Keywords - The words which are already defined in Java language. Eg: int, public, static.
int - Used to store integers. Its size is 32 bits.
long - Used to store big integers. It is of double the capacity than that of int. Its size is 64 bits.
double - It can be used to store integers as well as decimals.
char - It is used to store one character. Eg: char c = 'e'.
boolean - It is used to store true and false. All comparison operators return a boolean value.

Below is a function describing int and boolean data types. This function can be used to find greatest of 3 numbers. It also shows how to use nested ifs.
public class FirstJAVAClass {
public static void main(String[] args) {
System.out.println("Learning Selenium");
int x = 100;
int y = 200;
int z = 300;
if(x>y & x>z){
System.out.println("x is greatest");
}else if(y>z){
System.out.println("y is greatest");
}else{
System.out.println("z is greatest");
}
}
}

String - It is not a Data Type. It is an in-built class in Java.
===============*********************======================

No comments:

Post a Comment