About Selenium

Selenium is an open source automation testing tool for web based applications. Its easy to use, strong and is very flexible. You can work on many operating systems using selenium and you can code in any one of the following languages when using selenium.

Languages supported by Selenium
- Java
- C#
- Ruby
- Pyton
- PHP
- Pearl

Browsers supported by Selenium
- Mozilla(till latest version)
- IE 6,7,8
- Google chrome
- Opera8,9,10

The language which you use is independent of the language in which your application is made. Fox example if your application is made in C#, then you can use selenium with any languages mentioned above to test it. You need to know atleast one programming languages mentioned above in order to learn selenium.
Operating systems Supported by Selenium include windows, mac, linux, unix and many more.

Components of Selenium
- Selenium IDE: Installs as an addon in Mozilla.Only runs in Mozilla. Its got a strong feature of record and run. You can also extend IDE functionality with the help of user extensions. It supports regular extensions, loops, if statements and many other features. You can also parameterize your test cases using IDE. Click here to view 4 hours of Selenium IDE video tutorial.
- Selenium RC: This is the older version of selenium. It works on multiple browsers. RC can be implemented in any one of the programming languages mentioned abve. Click here to view a tutrial covering selenium RC installation and Selenium Tests.
- Webdriver: Webdriver is the new version of selenium. It also works on multiple browsers. Its removed many drawbacks and issues in Selenium RC. It also supports Android and Iphone Testing. Click here to view a tutorial on Webdriver installation and writing Selenium tests.
- Grid: Grid is used to run test cases parallely on multiple machines and browsers.

Certain Features which make it a strong tool to use are:
- Open source
- Works on multiple browsers and multiple operating systems as compared to other tools in market.
- You can develop selenium code and make it run parallely on multiple machines using different browsers.
- Support for Android and Iphone Testing.
- Selenium IDE is a simple tool which comes as an addon in firefox and is easy to use. It has the record and run feature which is very strong.
- You can also extend the functionality/scope of IDE with the help of many plugins available
- You can also create your own Selenium IDE plugins
- Selenium RC is the older version of selenium and is supporting all the languages mentioned above
- Webdriver is the latest version of selenium and is very strong. Its removed lots of drawbacks in RC and introduced many more features in selenium. – Selenium when used with Hudson can be used for Continuous integration.
- Object oriented datadriven or hybrid testing framework can be made very easily.
- You can use open source frameworks such as junit, testng, nuint etc and can write selenium test cases in them

Posted in - Selenium - | Leave a comment

TestNG

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use, such as:
•    Support for data-driven testing
•    Annotations :
o    @BeforeSuite
o    @AfterSuite
o    @BeforeTest
o    @AfterTest
o    @BeforeClass
o    @AfterClass
o    @BeforeMethod
o    @AfterMethod

It is parallel tool like. Generates the report automatically. Also we can integrate TestNG in eclipse.All you need to do is that Go to help  – - > Install new software – - > In Work with type http://beust.com/eclipse if your Eclipse in above 3.4 version else type http://beust.com/eclipse1.
Follow the instruction accept the agreement and all. Some downloading will happen. After all It will restart start the Eclipse. And if every is fine then you will see the TestNG Under Windows – - > Preferences.
If it is there it is configured. Now we are ready to write the TestNg test.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class LoginTest {

@BeforeTest
public void openConnection(){
WebDriver driver = new FirefoxDriver();
driver.get(“http://www.google.com”);
// db connection
System.out.println(“connected to database”);
}

@AfterTest
public void closeConnection(){

System.out.println(“closing the database connection”);
}

@BeforeMethod
public void openBrowser(){
// selenium
System.out.println(“Opening browser”);
}

@AfterMethod
public void closeBrowser(){
System.out.println(“Closing browser”);

}

@Test // annotation – represents test case
public void testLogin(){
// selenium code
System.out.println(“Executing logintest”);
}
@Test
public void testRegister(){
System.out.println(“Testing the registration”);
}

}

Now the Annotations:
@Test: This is used to create test. The things that you write in this annotation are executed as a TEST. And if you have more than one test in the class then they will be executed in an alphabetical order.
@AfterMethod: This annotation is used when we want to execute the before executing each test in the class.

@AfterMethod : This is used in conjunction @AfterMethod. And this is opposite to @AfterMethod. It means that everything that you write will be executed after executing the entire test.

@BeforeClass : If you want that something should execute once for all the tests, but not every time. Then you can use this annotation. It will execute only time for the entire tests.
e.g. you can open a browser for all the test in selenium.

@AfterClass : This is used for similar functionality like the BeforeTest but the difference is that the methods under this annotation are exceuted after the executing all the tests.

@BeforeSuite:  This is used do thing or the configuration for all the test, that are in a suite. You can put all your tests in a suite if you want to batch or suite.
In this annotation write the things that are to executed before executing any of the test in the entire suite.

@AfterSuite: This is used is you want something to happen after executing all the test of the suite.

Also you have to create a xml file if you want to execute all your test in  a suite.
The simple example of suite xml is like this:

<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”>
<suite name=”Your Suite Name “>

<test name=”Name of your test”>
<classes>
<class name=”package.inside.which.your.classfile.is” ></class>
</classes>
</test>
</suite>

A example of putting all the Annotations together:

import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class LoginTest {
@BeforeSuite
public void Init(){
System.out.println(“Initialization”);
}
@AfterSuite
public void End(){
System.out.println(“Ending Suite Run”);
}
@BeforeClass
public void OpenBrowser(){
System.out.println(“Opening browser”);
}
@AfterClass
public void CloseBrowser(){
System.out.println(“Closing Browser”);
}

@BeforeMethod
public void OpenBrowserM(){
System.out.println(“Opening browser”);
}
@AfterMethod
public void CloseBrowserM(){
System.out.println(“Closing Browser”);
}
@Test
public void LoginTest(){
System.out.println(“Running Login test”);
}

@Test
public void EmailTest(){
System.out.println(“Sending email test”);
}
}

We can also use the @DataProvider for the data driven testing like this :
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class SendMailTest {

@Test(dataProvider=”getData”)
public void testMailSending(String to , Integer sub, String msg){
System.out.println(to +” — ” + sub + “  —  ” + msg);
}

@DataProvider
public Object[][] getData(){

Object[][] data = new Object[2][3];
// 1st row
data[0][0] = “xyz@gmail.com”;
data[0][1] = 123;
data[0][2]  = “howzz life”;

// 2nd row
data[1][0] = “abc@gmail.com”;
data[1][1] = 444;
data[1][2]  = “life is good”;

return data;
}

}

Executing a test in TestNG gives this kind of result window:

Posted in - Selenium - | Leave a comment

Selenium Training – Day 3

Topics that we are going to cover are:

Local Variables
  Global Variables
  Static and Non-Static Variables
  Static and Non-Static Functions
  Creating Objects in Java
  Meaning of static
  Why is main method static?
  Object and Object References
  Call by reference and Value
  Constructors
  Usage of Objects in Selenium
Local Variables: Local variables are created when the method, constructor or block is entered and the variable will be destroyed once it exits the method, constructor or block.
e.g.  the variable inside the for loop is a local variable.

Global Variable: Global variable is something which has greater visibility than the local variables. We can have two global variables, one global non static variable; other is the static global variable.

Example of Local and global variable:
public static void main(String[] args) {
for(int i=1;i<=10;i++){
System.out.println(i);
}
System.out.println(i); // error here
}

When you try to print the value of “i” outside the for loop you get compiler error. This is because the variable “i” is local variable. And it can’t be accessed outside the for loop.
Static and Non-Static Variables: We can make a variable a static or non static. The difference between the two is that; if we mark a variable static then there will be only one copy of that variable in the memory no matter how many object has been created.
Example of static and non static variable is as follow:

public class StaticNonStatic {
int a = 10; // non static variable
static int b = 20; // static variable

public static void main(String[] args) {

StaticNonStatic  obj1 = new StaticNonStatic();
StaticNonStatic  obj2= new StaticNonStatic();
System.out.println(“Obj1′s a — “+obj1.a);
System.out.println(“Obj1′s b — “+obj1.b);
System.out.println(“Obj2′s a — “+obj2.a);
System.out.println(“Obj2′s b — “+obj2.b);
System.out.println(“Changing Values”);
obj1.a = 55;
obj1.b= 65;
obj2.a = 19;
System.out.println(“Obj1′s a — “+obj1.a);
System.out.println(“Obj1′s b — “+obj1.b);
System.out.println(“Obj2′s a — “+obj2.a);
System.out.println(“Obj2′s b — “+obj2.b);
}
}

If you run the above program it will produce the following output:

Obj1′s a — 10
Obj1′s b — 20
Obj2′s a — 10
Obj2′s b — 20
Changing Values
Obj1′s a — 55
Obj1′s b — 65
Obj2′s a — 19
Obj2′s b — 65

From the output we can see that the Number of copies of the variables that are not static are equal to the number of objects you have created. On the other hand there was only one copy of static variable. That was shared among all the objects. So if you see the code and the output, we changed the value of b using the obj1 but the changed value was reflected in obj2 also.

Why main() is static: We now the execution of a program start with main() function. To call the main function the JVM doesn’t  creates the object of the class. It call the main() directly. If don’t mark this function static it can’t be called by the JVM.

Objects in Java: There are two things in Java. One is object reference and other is object. Object reference can point different objects but not more than one at one time. There are many rules for this.

To create an object reference we can write like this:
ClassName obj ;
Here the obj is the reference. But it is not pointing to any object.
To create a reference we write like this
new ClassName();
By this we are creating a object. But there is no object reference to this object. It means that we can not call the functions, variable of this class.

Now if we want a reference for an object then :
ClassName obj = new ClassName();

This statement will create an object and obj will point to this reference.

Now the important thing

CONSTRUCTORS
A constructor is a special method that is used to initialize a newly created object. In order to create a Constructor observes the following rules:
1.    It has the same name as the class
2.     It should  not return a value not even void
It is optional to write constructor in our program. But constructor is always present in our program. If we don’t provide a constructor then JVM will provide a constructor of its own. And will be a default constructor, i.e. no parameters, no body.

You can have more than one constructor then one. i.e. you can overload the constructor.

public class MyClass {
public MyClass() {

}
public MyClass(String name){

}
private MyClass(int mbNumber){

}

public static void main(String[] args) {

}

}

Also if you are inheriting some class then the behaviour might look a little weird to you. Look at the following code and the output:

package qtpSelenium;
class A{
A(){
System.out.println(“Inside A”);
}
}
class B extends A{
B(){
System.out.println(“Inside B”);
}
}
class C extends B{
C(){
System.out.println(“Inside C”);
}
}
public class MyClass {

public static void main(String[] args) {
C c = new C();
}

}

•    * * * * * *  * * *  *    * * * * *  * *  * *   * * ** ** * *
Now look at the Output:

Inside A
Inside B
Inside C

If you expected this output then it’s OK. If not, then this is called chaining of constructor. i.e. constructor  of the parent is called before the constructor the child is executed.

A simple program to launch Mozilla Firefox and navigate to Google:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class WebDriverUse {
public static void main(String [] args){
WebDriver driver = new FirefoxDriver();
driver.get(“http://google.com”);
}

}

Make sure you have downloaded and added all the Jars if selenium.

Posted in - Selenium - | Leave a comment

Selenium training – Day 2

After we have installed Java and the Eclipse IDE, we will learn some more concepts of Java. So lets start with the concatenation operator.
Concatination Operators:  Using this operator we can concatenate two strings, strings with integer , also for adding two numbers.
Look at the following code:

public class Concatination {
public static void main(String[] args) {

String x = “Hello”;
String y = “World”;
int a,b;
a=25;
b=35;
System.out.println(x);
System.out.println(y);
System.out.println(x+y);
System.out.println(a);
System.out.println(b);
System.out.println(a+b);
System.out.println(x+y+a+b);
System.out.println(x+y+(a+b));
}

}

And look at the Output:

Hello
World
HelloWorld
25
35
60
HelloWorld2535
HelloWorld60

Look at the line in the output that I have highlighted. Don’t you find it weird? Ok. Why this happen. The reason is that first the string is concatenated with the other string, i.e. x is concatenated with y.
Then a is concatenated with the string before it is added with b. Hence this is the output.

Now, the loops. As we all know that if we want to repeat some number of steps, then we use loops.
There are three kinds of loops possible in Java. These are while, do-while and for. Mostly people use for loop.
A simple program to print 1-100 using these three is as follow:

1)    Using the for loop:

public class ForLoop {

public static void main(String[] args) {

for (int i=1;i<=100;i++){
System.out.println(i);
}
}

}

In this loop there are three things. First part is initialization, second is the condition and third is the increment or the decrement operator.

2)    Using the While loop:

public class WhileLoop {

public static void main(String[] args) {
int i=1;
while( i<=100){
System.out.println(i);
i++;
}
}

}

Ok. The thing that you must  look for is the expression that you write inside while, must be a Boolean expression.

3)    Using do-while loop:

public class Concatination {
public static void main(String[] args) {
int i=1;
do{
System.out.println(i);
i++;
}while( i<=100);
}
}

The same program using the do-while loop. The difference between the while and the do while is that the block inside the loop will be executed for one time for sure, even is the condition is not true

Arrays : In arrays we can have from single dimension to N dimension. To define a array we write like this:

Datatype[]  name_of_array = new data_type[size_of_Array];

This is the syntax to define an array. We can create array of primitive data types and non-primitive data types. For example to create an array of integer type we can write like this:

int a = new int[0];

So by this will create an array of integer type whose size is 5. So can store 5 integer values in it. Also it is important to take care of the index. It starts from 0 to 4. If you write anything else it will give you ArrayIndexOutOfBound exception.
The above example is for creating single dimensional array.

To create two dimensional arrays we write like this:

int[][] a = new int[5][5];

This will create two dimensional array. It will create array of size 25. We can use arrays in selenium for storing data. Like if we want to write a script to test Login of an application then we can use two dimensional arrays to store that.

In Java we can create n dimensional array.

Functions in Java: – Suppose we want to repeat some number of steps during our program. So it not so feasible to write the same steps again and again. So for this there are functions. There are lot of concepts about function in Java.  Like there can be functions of different kind. Like:
•    Function with no return type(void)
•    Function with return type(either primitive or non-primitive)
•    Function with parameters
•    And functions without parameters.

Example 1
I will give example of all the function (types) that I have mentioned here.

public class FunctionUse {
public void Display(){
System.out.println(“Display called”);
}

public static void main(String[] args) {
FunctionUse obj = new FunctionUse();
obj.Display();
}

}

Executing following program will produce this output:

Display called

This was the example of function with no return type and parameter.

Example 2
Now the example of function with Parameter but no return type. This is to check whether  the number is even or odd.

public void EvenCheck(int a){
if(a%2==0){
System.out.println(“Even”);
}else{
System.out.println(“Odd”);
}
}

public static void main(String[] args) {
FunctionUse obj = new FunctionUse();
obj.EvenCheck(12);
}

}

Executing this program will produce the following output:

Even

Example 3

Now let the function with return type:

public class FunctionUse {
boolean EvenCheck(int a){
if(a%2==0){
return true;
}else{
return false;
}
}

public static void main(String[] args) {
FunctionUse obj = new FunctionUse();
System.out.println(obj.EvenCheck(13));
}

}

This program will check whether the number is even or odd. It will print true if it is even, else it will produce odd.
So executing the following code will produce the following output

False

As the number 13 is not an even number.

Now if you are wondering what the hell is this public? It is access modifier. There are 4 access modifiers in Java. These are:
•    public
•    private
•    protected
•    and default

Posted in - Selenium - | Leave a comment

Selenium Training – Day 1

What is selenium? Selenium is a web automation tool using which we can automate the browser. There are many languages using which we can automate the browser. The languages are:
•    JAVA
•    C#
•    RUBY
•    PHYTHON
•    PERL
•    PHP
Here we are going to use Java language for writing the scripts. So how can we install Java on our machine? For that we need to have either the JRE or the JDK. If we are using some IDE like Eclipse or Net-Beans then the JDK is not required. Only JRE is sufficient.
To download the Java installer visits the website www.oracle.com/technetwork/java/javase/downloads/index.html.

As in this course we are going to do a lot of programming. So it is better to use some IDE. In this course we are going to use the Eclipse IDE. There are other IDEs also like Net-Beans, Intellij etc.
But the Eclipse IDE is the most popular IDE also easy to use IDE.
To get this IDE you can visit the official website of Eclipse IDE i.e. http://www.eclipse.org/downloads/.
Unlike the Java this is not an installer. Unzip the zip file that you have downloaded. And create the shortcut for the eclipse icon present in the folder.
Ok, now double click on the eclipse icon and launch the eclipse. Select the workspace i.e. the location where you want to store the all your programs.

Now to create your Java project go to file menu, select new and then Select Java Project. Give the name of the project and finish. As of now we don’t need to add any of the jars or the libraries.
When will use selenium then we will.

After this right click on the project and select New and then select the Class. Give the name of the class and finish.
Some code will be automatically generated, like this:

public class firstProgram {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

}

}

You can remove the thing that is comments like

/**
* @param args
*/

And // TODO Auto-generated method stub.

These are comments. You can keep them, you can remove then. Both will not affect the program.

So let’s write the code to print Learning Selenium in the console.

public class firstProgram {

public static void main(String[] args) {
System.out.println(“Learing selenium”);
}

}

Now press the green button on the top to execute the program. Executing this program will print this on the console:

Learing selenium

********************************************************************

Ok now what are the primitive data types available in Java.
So the data types that are permitted in Java are
•    int
•    long
•    char
•    float
•    double
•    Boolean

Also one important thing that you need to take care in the Java is that, it is a case sensitive language.
It means that I can have two variable like this:

int foo,FOO;

foo and FOO are two different variables.

A simple code using all the primitive data types and  if is as follow:

public class First_Java_Program {

// function
public static void main(String[] args) {

System.out.println(“hello world”);
// syso ->  cntrl+space
System.out.println(65465);

// DATATYPES
int x = 100; // cannot store decimals – 32 bits
System.out.println(x);
x=200;
System.out.println(x);

long var =3000L;// cannot store decimals – 64 bits
char c=’y'; // just one place
boolean b=true; // true or false

System.out.println(3>12);

int q=100;
int w=200;

boolean x1=q>w;

System.out.println(x1);

// IF statements
if(q<w){
System.out.println(“q is lesser”);
}else if(q==w){
System.out.println(“q is equal to w”);
}else{
System.out.println(“q is greater”);
}

// STRING class
String str = “hello how are you”;

}

}

Posted in - Selenium - | Leave a comment

Junit

JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of test-driven development, and is one of a family of unit testing frameworks collectively known as xUnit that originated with SUnit.
import org.junit.*;

public class TestFoobar{
@BeforeClass
public static void setUpClass() throws Exception {
// Code executed before the first test method
}

@Before
public void setUp() throws Exception {
// Code executed before each test
}

@Test
public void testOneThing() {
// Code that tests one thing
}

@Test
public void testAnotherThing() {
// Code that tests another thing
}

@Test
public void testSomethingElse() {
// Code that tests something else
}
@After
public void tearDown() throws Exception {
// Code executed after each test
}

@AfterClass
public static void tearDownClass() throws Exception {
// Code executed after the last test method
}
}

Let’s start with the annotation of Junit :
@Test
Using this annotation we can create a Junit test. We can run it. See the report in Junit.
@Before
Using this annotation we can write a method that can do the configuration or initialization for the tests.
This is executed before each test.
@After
It is used in conjunction with @Before but it is not a compulsion.  We can write a method with this annotation and the method will be executed after each test.

@BeforeClass
If you want a method to run once for all the methods, then you can use this annotation. It will execute the method once for all the tests of a particular file.

@AfterClass

It is used with the conjunction with the @BeforeClass. Use this method if you want execute a method after executing all the tests of a particular file.

@Parameters

Allows you to run the same test with different data by defining the data parameters. @Parameters have to return List [], and the parameter will pass into class constructor as argument.

@RunWith

Exclusively tells the class that the Junit Test Case uses Parameterized runner

Examples:

import java.util.Arrays;
import java.util.Collection;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
// step 1

@RunWith(Parameterized.class)
public class Parameterized_Test {
// step 2
// global vars
String bankName;
int actNum;

// step 3
// constructor
public Parameterized_Test(String bankName , int actNum){
this.bankName=bankName;
this.actNum=actNum;
}

@Test
public void checkBalanceTest(){
System.out.println(“Executing the test with – “+bankName + ” — “+ actNum );
// selenium code
// bank name
// act number
}

// step 4
@Parameters
public static Collection<Object[]> getData(){

Object data[][] = new Object[2][2];
// first row
data[0][0]=”HSBC”;
data[0][1]=1234;

// 2nd row
data[1][0]=”City”;
data[1][1]=123455;
return Arrays.asList(data);
}
}
Running this file will produce this output.

Junit comes in built in eclipse. You don’t have to add any extra jar in your project, unlike TestNG.
There you can select the version of the Junit that you want to use.

A sample  screen:

JUnit

Posted in - Selenium - | Leave a comment

Selenium IDE – 2

Ok, now we will start with the comuser

In Selenium Core extensions (user-extensions.js) click on the browse button and select the user-extensions.js that you have downloaded from the website of the selenium.
And now you will get all the commands like goBack, if and all the commands that are in the file.
If the commands are not coming in the IDE restart it. They will all come.
COMMANDS
store:  if you want to store some values in your some variable then you can use this command
in command write store, in target write the value, and in value the variable name in which you want to store it.
Also you can use this command to print the value of stored values.
Echo – in command
javascript{storedVars['b']} – in target

If you want to store the value of some variable in some new variable than write like this:
Store – in command
${b} – in target
C – in value

While:  People say we can’t have loops in the Selenium IDE. But that is not true. We can. It comes in the user-extension.js file. If you have added them in your  IDE then you can use them. A simple program to print the first 10 numbers using while loop

Posted in - Selenium - | Leave a comment

Selenium IDE – 1

Topics that are covered in this post:
•    Installing IDE
•    Recording Script
•    Running Pausing and debugging the script
•    Running a script line by line
•    Inserting a command in between a script
•    Xpaths and Installing Firebug to get the Xpath
•    Wait command
•    Verification and Assertions
•    Should I use verify or assertion
•    User-extentions.js in IDE
•    Using if and loops in the IDE
•    Echo, storeEvals and storedVars Demystified
•    Making a function is User-extension to generate random emails address
•    Reading XML from javascript using the DOM
•    Parameterize your IDE test cases with customised user extension and XML
•    Creating your own user extensions
•    Regular Expression in Selenium IDE
•    Handling JavaScript Alerts
•    Popup and Tabs
•    Extracting all values of dropdown
•    Capturing screenshots from selenium IDE
•    Handling Ajax components with IDE
•    Converting codes from IDE to RC and WebDriver
•    Testing flash application with IDE – Selenium Flex API

We have taken the website www.salesforce.com where we have implemented five test cases
1.    Login test – Verification, Assertion
2.    Check date – Regular Expression
3.    Create lead – Popup Verification, Assertion Using variable Xpaths
4.    Create task – Pop handling and attaching files
5.    Delete Lead – Handling java script messages

So lets talk about the website first.
www.salesforce.com is a CRM website which helps the sales people to keep record about there potential people. They can create, delete, and modify their leads.

Some people ask us if we can do things in IDE then why use the Selenium WebDriver or Selenium RC. Answer is:
1.    If you script has too may test script 1000 or so, then it is very difficult to maintain that using IDE.
2.    It is not consistent. You need to understand the Java script in detail. And many other things.
The similarity between the Selenium IDE and Selenium RC is that, core of both is made in JavaScript.

Now, the first thing that you need to know is how to install the Selenium IDE.
Selenium IDE gets installed as add-on in Mozilla Firefox. You can download the Selenium IDE form this URL : http://seleniumhq.org/download/. And it will be added automatically in your browser.
And if you’ll see Selenium IDE under tools. And this is the disadvantage of Selenium IDE, i.e.  it works in Mozilla Firefox only.

If you open it, it looks like this.  Selenium IDE

It is similar to other automations tools. It records the actions you do in your browser. By default it is in recording mode. So whatever you do it will record it. You can press red button to start and stop the recording.

All your command that you see recorded also comes in the drop down. You can write the steps yourself too. Also you can add more command of your own. We will talk about adding command later.
The Base URL will be the website that you want to test. And open will have sub URL.

Now after recording you script you can play it or run it, by clicking on the green button. One is to run current test case. And other is to run entire test suite.

We can also insert the breakpoints in the script. For this select the line of code on which you want to insert the breakpoint. Right click on it. Select “Toggle Breakpoint”. And if you will run this, it will stop at the Breakpoint. This can be helpful in finding the bugs or in any other need. Now if you run your script using the break point it will stop at the line which has breakpoint. Also it will be highlighted.

IDE Commands
Also two other buttons Pause/Resume (Yellow and Green in colour) and Step (Blue) will be highlighted. Clicking on step will run the script one step.
You can also increase decreases the speed of execution of IDE.

Assertion and verification
•    Verifications are used to verify something. Say I want to verify my page title. So We’ll use the command verifyTitle. If the verification passes then its good. But even it will fail, the script will not stop. The line will be highlighted.
•    On the other hand the assertions are a little different. If the assertion fail, then the script will not move ahead. Same thing i.e. to verify the page title can be done using the assertion. Now instead of verifyTitle We’ll write assertTitle and in the target the title against which we want to verify that.
So depending o n your requirement you can choose from the two.

Posted in - Selenium - | Leave a comment

Install Selenium IDE

Selenium IDE can be installed from selenium’s site: http://seleniumhq.org/download/
It is installed as an add-on in Mozilla firefox and only works in mozilla.
Its got a good user interface. Record and Run is the major feature of IDE.
Many selenium developers/people think that its just a record and run tool.
Selenium IDE is having the core engine which is based on javascript. You can also write your own code in java script and extend the functionality of IDE. For example, we can read the test data from XML in IDE. Javascript code will be written using user extensions(generally named user-extensions.js) There are many other things which you can do with selenium IDE. You can write programming logic using if statements, while loops etc. People have contributed all this in form of plugins. Plugins are nothing but java script code written by someone else which you can use in your selenium tests. There are plugins for flash testing, plugins for test organzation etc.

Posted in - Selenium - | Leave a comment