0% found this document useful (0 votes)
70 views5 pages

Selenium Is An Open Source Web Application Test Automation Tool

The document discusses how to set up Selenium with Eclipse. It provides steps to create a Java project in Eclipse, add the Selenium client driver to the build path, write a sample test class to perform a search on Google, and run the test. It also explains how to start the Selenium server separately which is required to run Selenium tests from Eclipse.

Uploaded by

rajibranjan7338
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
70 views5 pages

Selenium Is An Open Source Web Application Test Automation Tool

The document discusses how to set up Selenium with Eclipse. It provides steps to create a Java project in Eclipse, add the Selenium client driver to the build path, write a sample test class to perform a search on Google, and run the test. It also explains how to start the Selenium server separately which is required to run Selenium tests from Eclipse.

Uploaded by

rajibranjan7338
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

Selenium is an open source web application Test Automation tool. Learning Selenium is very easy.

Anybody who worked on manual testing can easily learn Selenium. We will try to explore how to learn Selenium Step by Step.

Selenium has three main tools Selenium IDE, Selenium RC, and Selenium Grid.

First let us have a look at Selenium IDE

Selenium IDE This is a Firefox Add-on (download from openqa download page). Download Selenium IDE and install. Once the IDE is installed, go to tools > click Selenium IDE. This opens up the Selenium IDE as below:

Once this is done, close the Selenium IDE.

Now let us record a test:

1. 2. 3. 4. 5. 6. 7. 8.

Open a new browser Navigate to www.google.com Click tools > Selenium IDE (opens up IDE) click on Advanced Search link on Google search page type selftechy in all these words: edit box Select 20 results from Results per page drop down Click Advanced Search button Click on File (on Selenium IDE) > Save Test Case As and then give it a name and save the test case

Selenium IDE has recorded around 3-4 test steps. Starting from the first step > right click on each step and then click Execute this command. Execute all the commands one by one.

Try to record some more tests with even more complexity and also record more number of tests. Then try to execute each tests as explained above. By this way you can become more comfortable with Selenium IDE. After this exercise we can go ahead and try to learn exporting the tests in different formats such as Java, JUnit, PHP, C#, etc and also setting up the Selenium RC with Eclipse.

Below are the drawbacks of using Selenium IDE for record and execute tests:

1.

If all the test steps are executed together then the chances of tests getting failed is more because of page load time / objects taking more time to appear on the web page

2. 3.

Parameterization is difficult and values should be hard coded Maintenance is much more difficult, etc.

Setting up Selenium with Eclipse by SEETARAM on MAY 31, 2011 In my earlier post I have explained how to setup Selenium with Eclipse but there I have utilized example of SugarCRM. So, in order to avoid downloading SugarCRM I thought of writing one more post on the same topic which uses Google as example.

Eclipse is an open source Integrated Development Environment which supports multiple languages. Most of the java developers use Eclipse IDE for software development as it is highly extensible with plug-in system and user friendly. We can add external libraries to build path in order to utilize any external APIs available.

In order to setup Selenium in Eclipse, Selenium-Client-driver needs to be added to the Java build path - >Libraries

In the below example, we will discuss setting up Selenium in Eclipse Step-by-Step.

For this purpose I will utilize Advanced Google Search example.

1. 2. 3. 4. 5.

Download the latest Eclipse release from www.Eclipse.org Create a project. In my example -> PracticeCode. (File ->New-> Java Project ->Give name as PracticeCode) Create Package under this project ->com.selftechy.parameterization Under this package > create a new class (AdvancedSearch.java) Add Selenium-Client-Driver (this needs to be downloaded from www.seleniumhq.org)to Java Build Path of the project: Right click project (PracticeCode) Click Properties Click Java Build Path Click Libraries Click Add External Libraries Select the Selenium-Client-Driver

Open AdvancedSearch.java class and copy the following code:

package com.selftechy.parameterization;

import com.thoughtworks.selenium.*;

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

public class AdvancedSearch extends SeleneseTestCase {

@Before

public void setUp() throws Exception {

selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.co.in/");

selenium.start();

@Test

public void testAdvancedSearch() throws Exception {

selenium.open("http://www.google.com/");

selenium.click("link=Advanced search");

selenium.waitForPageToLoad("30000");

selenium.type("as_q", "selftechy, selenium, eclipse");

selenium.select("num", "label=20 results");

selenium.click("//input[@value='Advanced Search']");

selenium.waitForPageToLoad("30000");

@After

public void tearDown() throws Exception {

selenium.stop();

In the above code we can see extends SeleneseTestCase and import com.thoughtworks.selenium.*; these two phrases tell Eclipse that we are going to use Selenese commands in the subsequent methods.

In order to run this test case we need to start the Selenium Server first. Follow the steps below to run the Selenium server.

Download Selenium Server from www.seleniumhq.com Step 1: Create a new text file

Step 2: Open the file and type in following code into it (D:\Workspace-Helios should be changed to the path where selenium-server.jar file is copied)

CD D:\Workspace-Helios java -jar selenium-server.jar -multiWindow (Dont copy and paste as it sometimes adds some special characters)

Step 3: Save it as Selenium-server.bat

Step 4: Double click the selenium-server.bat, this should start the selenium server.

Step 4: Still if you are not able to run, then execute both the commands in command prompt (Click Start -> Run ->cmd).

To run the AdvancedSearch.java > Right click the file and click Run As > JUnit Test

This opens up firefox and executes the test.

You might also like