Thursday, November 3, 2011

How To Run Selenium Script In Eclipse

-Dhivya Seethapathy
I would like to share how to run the selenium script in Eclipse through this blog . But before to list out the steps that i have followed, i would like to give a brief introduction about what exactly Selenium is?
 
Selenium is a portable software testing framework for web applications Selenium provides a record/playback tool for authoring tests without learning a test scripting language. Selenium is an open source tool for web application testing. This tool is primarily developed in Java Script and browser technologies and hence supports all the major browsers on all the platforms.

Selenium IDE is an integrated development environment for Selenium scripts. It is implemented as a Firefox extension, and allows you to record, edit, and debug tests.

Selenium Remote Control (RC) is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser.

Why Selenium:
  • Its Open source!!
  • It’s easy to learn and implement.
  • Supports multiple browsers.
  • Supports multiple scripting/programming languages.
  • Flexible to your choice, simple record and playback (IDE), Complex Framework design to your choice by using your favorite programming language.
Here I would like to share how to run the selenium script in Eclipse.
Steps to run the selenium script in eclipse:

Step 1: Download required components
1. Download Eclipse IDE: http://www.eclipse.org/downloads/
2. Download Selenium RC: http://seleniumhq.org/download/
3. Download JUnit: http://www.junit.org/

Step 2: Record and save the java selenium script
  • Open Firefox and enter the URL to browse your application.
  • Launch IDE from Tool menu.
  • Record your script.
  • Choose the programming language as JAVA and save your script. To choose the language, go to Option-> Clipboard format and select JUnit 3 (Remote Control).
  • Now you have a java code. I am making it simple and not covering scripting in detail. My motive is to share you the end to end process of using this IDE and RC to run a simple test using Eclipse. Rest you can change your script as per your need.
Step 3: Create a java project in Eclipse
 The first step in eclipse is to create a java project to do this follow the steps below
  • Launch Eclipse.
  • Click on File > New > others > select java project.
  • Enter the java project name as First Project (for example).
  • Click on finish button.
Step 4: Add selenium java client jar and JUnit library to your project
  • Right click the project and select the properties.
  • Go to java build path and select libraries tab.
  • Click add external jars.
  • Browse and add the selenium-java-client-driver.jar and junit4.jar from the source where you had saved it.
Step 5: Initiating the Selenium Server
  • Open the command prompt and run the selenium RC by below command.
  • D:\selenium-remote-control-1.0.3\selenium-server-1.0.3> java -jar selenium-server.jar
  • After entering that command, the selenium server will start in your machine.
Step 6: Adding your test script in our Project
To add your test (which you have saved earlier) as a java class file to the project (FirstProject, already saved) follow the below steps:
  • In eclipse right click the project FirstProject select new > class
  • Enter the class name as MyFirstTest.
  • Paste the recorded code from the file you had saved it.
  • Choose "com.thoughtworks.selenium.SeleneseTestCase" as its super class.
  • Finish it.
Step 7: Modifying your test script
Once you are done with your class file, it will look like,

Package.*

import com.thoughtworks.selenium.SeleneseTestCase ;

public class MyFirstTest extends SeleneseTestCases

{

  public void setUp() throws Exception

  {

  setUp( " http://www.google.com/ " , "*firefox”);

  }

//............ Your test script..............

 public void testUntitled() throws Exception

  {

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

  assertEquals("Google", selenium.getTitle());

  selenium.type("id=lst-ib", "selenium");

  selenium.click("name=btnG");

  }

}


In case you want to run this in different browser then simply you can change your script.
setUp( " http://www.google.com/ " , "*firefox”); to setUp( "http://www.google.com/ " , "*chrome”); or whatever browser you need to run.

Step 8: Running your test
Finally we are ready to run our first test. To run this in eclipse you click on Run button. Select option Run as "JUnit Test”.

Note: One thing I forgot to mention that if you have eclipse with JRE version lower than 1.5 in build path, it will show some error related to version not supporting. To resolve this you have to remove the default Eclipse JRE and add JRE version 1.5 or more to System Library in Build Path.
To add this follows the steps:
  • Go to Java Build path and select Libraries tab.
  • Under this select JRE system Library.
  • Remove your default one.
  • Now click on add Library and select JRE system Library and click next.
  • Add JRE.
  • Now add this JRE to your class path.
So finally I am done with your end to end execution of java test script using selenium RC in Eclipse.


214 comments:

«Oldest   ‹Older   201 – 214 of 214
crackedfull said...

KeepVid Pro Crack Key Download Full Registration Code KeepVid Pro Crack supports you to download online videos and audio on your computer hard drive
https://crackfullstore.com/keepvid-pro-crack/

Hurrain said...




This is an excellent piece of writing. Keep sharing fantastic content on your page. Your blog is wonderful.
EndNote

Always Crack said...

It’s not my first time to pay a quick visit to this website, I am visiting this site dailly and obtaining fastidious data from here daily.
Virtual DJ Pro Keygen

Anonymous said...


Low competitor Keyword For Crack 2023

Free Download 4 Paid Software Crack

David said...

Fantastic article. Continue posting such material on your blog. It has really impressed me. benefits of having big boobs

Sunflow said...

Thank you so much for share this information. I really appreciate your work because your content is unique. iobit driver booster pro crack

USA Essential Needs said...

2022 Best Cheap Commercial Grade 140 Pint Dehumidifier With Built-In Drain Hose Pump
is an air conditioning device which reduces and maintains the level of humidity in the air. This is done usually for health or thermal comfort reasons, or to eliminate musty odor and to prevent the growth of mildew by extracting water from the air.

em-client pro professional version said...

Creating & very informative article. I’ve end up being your fan of your blog. You may tragically checkout my work.You have made awsome details info and blogs. really impressive. for more blog visit my site also
Zoner photo studio X crack new version

em-client pro professional version said...

Creating & a very informative article. I’ve ended up being a fan of your blog. You may tragically check out my work. for download free software, visit my site also
Sony Vegas Pro crack free download

hubert said...

StudioLine Photo Classic allows you to annotate your pictures with text, adjust the opacity, and rotate the pictures in any direction you choose.
https://thepcsoft.com/studioline-photo-classic/

dani said...

nuberol forte uses Nuberol Tablets Forte (450 MG 650 MG) contains a generic named medicine “Orphenadrine and Paracetamol

Activator Software said...

F-Secure Internet Security Crack

F-Secure Internet Security is important safety which consumer can employ their appliance fret-gratis for live expenditure, shopping, still mesh surfing.

hadiya said...

Its a very effective software install and download freesteganos privacy suite crack

ibraham said...

Microsoft opening working outline device Bluestacks 5.11.100.2102 With Crack Download For PC [Latest]

«Oldest ‹Older   201 – 214 of 214   Newer› Newest»