Archive for the ‘Java’ Category

How to create test suite using Junit and eclipse in selenium

How to create test suite using Junit and eclipse in selenium

There are some scenarios where we need to run multiple test cases. Either we can run those test cases independently or together. But there are some real time cases where we need to run our test cases in a particular order. In this case we would prefer Test Suite to combine the test cases together and decide their orders and run those.

Below are the steps

1. Create a Test Suite class where we create the Test Suites which will call all the test cases in a particular order.


import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;  
import junit.textui.TestRunner;

public class TestSuite1 extends TestCase {

public static Test suite()  
{  
TestSuite suite = new TestSuite();  

suite.addTestSuite( TestCase1.class);  
suite.addTestSuite( TestCase2.class);
suite.addTestSuite( TestCase3.class);  
return suite;  
}  

public static void main(String arg[])
{
TestRunner.run(suite());

}
}

Step 2. Create your first test case


import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.*;
public class TestCase1 extends SeleneseTestCase{

Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS="60000";
private SeleniumServer seleniumServer;

public void setUp() throws Exception {

RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setSingleWindow(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
seleniumServer.start();
selenium.start();

}
public void testgoogling() {
selenium.open("/");
selenium.type("q", "Niraj");
selenium.click("btnG");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
assertTrue(selenium.isTextPresent("Niraj"));

}

public void tearDown() throws InterruptedException{
selenium.stop(); 
seleniumServer.stop();
}
}

Step 3. Create your second test case

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.*;
public class TestCase2 extends SeleneseTestCase{
Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS="60000";
private SeleniumServer seleniumServer;
public void setUp() throws Exception {

RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setSingleWindow(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
seleniumServer.start();
selenium.start();
}

public void testgoogling() {
selenium.open("/");
selenium.type("q", "Niraj Kumar");
selenium.click("btnG");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
assertTrue(selenium.isTextPresent("Niraj Kumar"));

}

public void tearDown() throws InterruptedException{
selenium.stop(); 
seleniumServer.stop();
}
}

Step 4. Create your third test case

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.*;
public class TestCase3 extends SeleneseTestCase{
Selenium selenium;
public static final String MAX_WAIT_TIME_IN_MS="60000";
private SeleniumServer seleniumServer;
public void setUp() throws Exception {

RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.setSingleWindow(true);
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/");
seleniumServer.start();
selenium.start();
}

public void testgoogling() {
selenium.open("/");
selenium.type("q", "http://www.automationtricks.blogspot.com");
selenium.click("btnG");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
assertTrue(selenium.isTextPresent("http://www.automationtricks.blogspot.com"));

}

public void tearDown() throws InterruptedException{
selenium.stop(); 
seleniumServer.stop(); 
}
}

Step 5. Run your Test Suite
Go to your Test Suite class and right click on that and run as Junit Test.

This will run the TestCase1 then TestCase2 then TestCase3

If you want to execute your test cases in some specific order then you call them in that order like.

suite.addTestSuite( TestCase3.class);  
suite.addTestSuite( TestCase2.class);
suite.addTestSuite( TestCase1.class);  

Above will run the TestCase3 first then TestCase2 then TestCase1.

Upgrading Selenium Standalone Server

Upgrading Selenium Standalone Server

I have started writing this blog from 3 months. When I have started writing the latest Selenium Standalone Server version available for download was 2.31.0.

Now I would like to check if there are any latest version available by following the below steps:

1. Open www.seleniumhq.org
2. Click on ‘Download’ tab to navigate to the downloads page as shown below:

3. In the Download page, view the latest version of the Selenium Standalone Server as shown below:

4. I’ve observed that there is a new version 2.32.0 for Selenium Server available for me to download  (currently I and using 2.31.0 version). So I would like to upgrade it to the latest version by following the below steps.

Upgrading to the Latest Selenium Server:

Pre-requisite: Ensure that Selenium Standalone Server is not running. If it is running, just restart the Eclipse IDE to stop it.

1. Download the Selenium Servers new version 2.32.0 and place the downloaded file in any folder as shown below:

2. In Eclipse IDE, Right click on the Project you are working with and select ‘Properties’ option as shown below:

3. Ensure that ‘Properties for Project’ dialog is displayed, select the older version of Selenium Server and click on ‘Remove’ button as shown below:

4. Ensure that the older version of Selenium Server is removed and click on ‘OK’ button as shown below:

5. Expand the libraries folder, right click on the older version of Selenium Server and click on ‘Delete’ option as shown below:

6. Click on ‘OK’ Button on the ‘Confirmation’ dialog as shown below:

7. Ensure that the older version got deleted from the libraries folder
8. Copy the latest version as shown below:

9. Paste the copied latest version into the libraries folder as shown below:

10. Ensure that the latest Standalone Server 2.32.0 got pasted into the libraries folder as shown below:

11. Right click on the Project and select Properties option as shown below:

12. Ensure that ‘Properties for Project’ dialog is displayed and click on ‘Add Jars’ button as shown below:

13. Ensure that ‘Jar Selection’ dialog is displayed, explain the Project -> libraries folder, select the latest selenium standalone version and click on ‘OK’ button as shown below:

14. Ensure that the latest Selenium Server version got added in the ‘Libraries’ tab and click on ‘OK’ button as shown below:

15. Select ‘External Tools Configuration’ option from the Run options as shown below:

16. Ensure that ‘External Tools Configuration’ dialog is displayed, change the version details in the ‘Argument’  text box and click on ‘Apply’ Button as shown below:

17. Click on ‘Run’ Button to start the ‘Selenium Server’ as shown below:

18. Ensure that the Selenium Server is running as shown below:

19. Run the ‘Class16.java’ file by selecting the ‘JUnit Test’ option as shown below:

20. Ensure that the Test got passed without any errors as shown below:

Watch the Below Video:

Click Here to watch the Video

Download this Project:

Click here to download this project and import into Eclipse IDE  on your machine.

Only one test should be written inside a test method

Only one test should be written inside a test method

1. Before going forward, lets once again view the code we have written in our previous post below: (i.e. The code with more than one tests inside a single test method)

2. As its not a good idea to write more than one tests inside a single test method, lets Refactor the Selenium Automation code by writing all the 3 tests into a separate test methods as shown below:

3. Start the Selenium Standalone Server
4. Save and Run the ‘Class16.java’ file by selecting the ‘JUnit Test’ option
5. In this case, Observe that the Firefox Browser has launched and closed for 3 times instead of once,  for performing the above three tests as shown in the below video.

Watch the Below Video:

Click Here to watch the video.

Download This Project:

Click here to download this project and import into Eclipse IDE  on your machine.

Why did the firefox launched and closed separately for each test method in the code ?

As we’ve three tests and we’ve written test method for each of our tests, hence we got 3 test methods in the Selenium Automation code. But in this case ‘chapter1’ page is common for 3 of the tests and hence its not required to close the application and launch it for performing the remaining tests. This has happened because of @Before and @After JUnit annotations.

The code inside the @Before and @After annotations will be executed once for each test method in our Selenium Automation code. Since we’ve three test methods in our code,  the methods under the @Before and @After got executed thrice (i.e. once for each test method).

How to resolve this problem ?

Suppose if we want to run the methods under the @Before and @After annotations only once, we’ve to replace these annotations with @BeforeClass and @AfterClass. (i.e. The method under @BeforeClass will be executed before executing all the test methods inside the class and The method under @AfterClass will be executed after executing all the test methods inside the class.

So to conclude the executing process will be as shown in the below screenshots:

@Before and @After:


@BeforeClass and @AfterClass:

You can research for implementation for the @BeforeClass and @AfterClass Annotations as well for confirmation.

How to Start IE9 using Selenium RC in Windows Vista or Windows 7

Selenium RC – How to Start IE9 using Selenium RC in Windows Vista or Windows 7

Issue:

When I started to work on the Selenium RC, it was running the tests against IE6 and that makes sense if the tests were written 3 years ago and code was never updated since then. Now the challenge here is to run all the tests of the projects I was working on, in Windows 7 machine instead of WinServer 2003 and running the tests against IE9 instead of IE 6.

Solution:

There are couple of simple solutions you can try to get these things done and working properly in your new environment.

1. Check your Server version. If you are using very old selenium version then its the time to get the latest Selenium Server from the Selenium Website.

2. Command Prompt. You will also have to make sure that the command prompt you are working on to run the Selenium Server is opened as “Run as Administrator“. This is one of the reasons that you might not be able to open IE latest version with Windows Vista and Windows 7 i.e. IE9.

3. Disable Protected Mode. This is an alternative trick to solve the issue and run the tests against IE9. You will have to go to IE | Internet Options | Security | Enable Protected Mode and then Uncheck the box and click on Apply and Ok. That is it and it will resolve the issue. Please go to my other blog where I have mentioned everything step by step how to do this.

Now we are good to go and run our tests against IE7, IE8, IE9 with either Windows Vista or Windows7.

How to do database testing using selenium rc

How to do database testing using selenium rc?

There are no selenium specific commands to do the database testing. But, you have the work around with native language. Here is the example how you can make database testing in selenium. The below mentioned commands will help you to begin with.

Before you use the below code You should have created the DSN name for MS SQL Server DB or Oracle DB using ODBC drivers. Here the name that we have used for the database DSN name is QT_Flight32. And the table in that database we are using is Orders. Hope the remaining steps you can easily understand.

//KEEP THE NAME OF THE PACKAGE
package com.src.test;

//IMPORT THE SQL PACKAGE
import java.sql.* ;

//DECLARE THE CLASS
class JDBCODBCTestCase
{

//WRITE THE MAIN METHOD TO CONNECT TO THE DATABASE
public static void main( String args[] )
{

try{

// LOAD THE DATABASE DRIVER
Class.forName( “sun.jdbc.odbc.JdbcOdbcDriver” ) ;

// ESTABLISH THE CONNECTION TO THE DATABASE
Connection conn = DriverManager.getConnection( “jdbc:odbc:QT_Flight32” ) ;

// GET A STATEMENT FOR THE CONNECTION
Statement stmt = conn.createStatement() ;

// PREPARE THE SQL STATEMENT
String strSQL = “SELECT * FROM Orders”;

// EXECUTE THE SQL QUERY AND STORE IN RESULTS SET
ResultSet rs = stmt.executeQuery( strSQL ) ;

// LOOP THE RESULT TILL IT REACHED END
// rs.getString(1) – FIRST COLUMN
// rs.getString(2) – SECOND COLUMN ETC
while( rs.next() )
System.out.println( rs.getString(1) + rs.getString(2)+ rs.getString(3)+ rs.getString(4)) ;

// CLOSE THE RESULT, STATEMENT AND CONNECTION
rs.close() ;
stmt.close() ;
conn.close() ;

}
// HANDLE THE SQL EXCEPTION
catch( SQLException se ) {

System.out.println( “SQL Exception:” ) ;

// PRINT TILL ALL THE ECEPTIONS ARE RAISED
while( se != null ) {

System.out.println( “State : ” + se.getSQLState() ) ;
System.out.println( “Message: ” + se.getMessage() ) ;
System.out.println( “Error : ” + se.getErrorCode() ) ;

se = se.getNextException() ;

}

}
//CATCH THE CLASS EXCEPTION
catch( Exception e ) {

System.out.println( e ) ;

}
}

}

Using *safari for Running our Tests on Safari Browser

Using *safari for Running our Tests on Safari Browser

After a lot of research I’ve found that only the following combination works for running our tests on Safari Browser:

Mac OS + Safari Browser -> This will work without any problems.
Windows 7 + Safari Browser -> This may run the tests but the final result will fail though the test executed without any fails. Hence not suggested.
What happened when I tried Running Selenium RC Tests on Windows 7 OS + Safari Browser:
1. I disabled the Pop-Up blocker in Safari Browser as  shown below:
2. Copied the Safari Folder path in C:/Program files as shown below:
3. Click on ‘Start’ Button, Right Click on the ‘Computer’ option in the start Menu and select ‘Properties’ option as shown below:
4. Click on ‘Advanced System Settings’ option and ensure that the ‘System Properties’ dialog is displayed.  In the ‘Advanced’ tab of ‘System Properties’ dialog select ‘Environment Variables’ button as shown below:
5. Ensure that ‘Environment Variables’ sub dialog is displayed, select the Path variable and click on ‘Edit’ button as shown below:
6. Ensure ‘Edit User Variable’ sub dialog is displayed and add a semi colon at the end of the existing statements followed by pasting the above copied path in step 2 into the Variable Value field and click on ‘OK’ button as shown below:
7.  Click on ‘OK’ buttons on the remaining ‘Environment Variables’ and ‘System Properties’ dialog.
8.  In Eclipse IDE, I’ve replaced *iexplore with *safari and Ran the Selenium RC Test using JUnit Test option. Unfortunately the Test didn’t Run.
9. So I have then replaced *safari with *safariproxy as shown below:
 10. Start the Selenium Standalone Server
11. Run the Test using JUnit Test option and observe that the Test Ran this Time in Safari.
12. Though the Selenium Test executed successfully, the Test has resulted as Fail though there are no failures as shown below (i.e. com.thoughtworks.selenium.SeleniumException: ‘undefined’ is not an object is displayed as error )
 Watch the below video:

Click here to watch the video.

Download this Project:

Click here to download this project and import into Eclipse IDE  on your machine.

NOTE : After lots of research activity its found that Running Selenium RC Tests on Safari Browser of MAC OS X machine will work without any errors. I am not going to explain this practically on MAC machine. Please try yourself.

Using *iexplore for running the Selenium RC Automation tests on Internet Explorer Browser

Using *iexplore for running the Selenium RC Automation tests on Internet Explorer Browser

*iexplore is used to run the Selenium RC Automation Tests on Google Chrome Browser.

Lets Implement This:

1. Replace *firefox with *iexplore in the project explained in our previous post as shown below:

2. Start the Selenium Standalone Server
3. Save and Run the ‘Class15.java’ file by selecting the ‘JUnit Test’ option
4. Observe that the following Script Error is displayed as shown below:

5. We got this Script Error as we are not running the Eclipse IDE in Administrator mode. How to resolve this Script error and Run the Selenium RC Automation Test on Internet Explorer will be explained in the  next steps. In order to run the Eclipse IDE in Administrator mode please follow the below steps.
6. Close the Eclipse IDE by clicking on ‘X’ button as shown below:

7. Ensure that the Eclipse IDE is closed and open the Folder where you have downloaded the Eclipse IDE as shown below:

8. Right click on the ‘eclipse.exe’ file and select ‘Run As Administrator’ option as shown below:

9. Click  ‘Yes’ button if the User Account Control dialog asking the User “Do you want to allow the following program …”  is displayed as shown below:

10. Click ‘Ok’ on the ‘Workspace Launcher’ dialog as shown below:

11. Ensure that the Eclipse IDE is now launched (i.e. in Administrator mode this time).
12. Start the Selenium Standalone Server
13. Save and Run the ‘Class15.java’ file by selecting the ‘JUnit Test’ option and observe that the Test is Run in Internet Explorer without any Script errors this time as shown below:


Watch the below video:

Click here to watch the video.

Download this Project:

 Click here to download this project and import into Eclipse IDE  on your machine.

Using *firefox for running Selenium RC Automation Tests on Firefox Browser

Using *firefox for running Selenium RC Automation Tests on Firefox Browser

Pre-requisites:  Go through “Ensure Compatible Firefox Browser is Installed”

*firefox is used to run the Selenium RC Automation Tests on Firefox Browser.

Lets Implement This:

Pre-requisites:

1. Create a new Project say ‘RC-Project15’ in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Start the Selenium Standalone Server
5. Create a package say ‘package_Fifteen’ under the newly created project.
6. Create a Java Class file say ‘Class15’ under the newly created package as shown below:


Actual Steps:

1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:

2. Start the Selenium Standalone Server
3. Save and Run the ‘Class15.java’ file by selecting the ‘JUnit Test’ option and ensure that Selenium RC Automation Test is Run in Firefox Browser as shown below:

Watch the below video:

Click here to watch the video.

Download this Project:

 Click here to download this project and import into Eclipse IDE  on your machine.

Writing Selenium RC Test on our own

Writing Selenium RC Test on our own

Earlier in order to create a JUnit Selenium RC Test, we have performed the following steps:
  1. Recorded a Test Scenario using Selenium IDE
  2. Copied the Selenium  RC code generated by the Selenium IDE
  3. Pasted the code into the Eclipse IDE
  4. Resolved few errors and warnings
  5. Run the Selenium RC test using JUnit in Eclipse IDE
Please refer to “Create a JUnit Selenium RC Test using Selenium IDE”
But how not to use Selenium IDE and write Selenium RC Test on our own. In order to understand how to write Selenium RC Tests on our own, we’ve to start writing the code from Scratch.
Writing Selenium RC Tests on our own (i.e. without using Selenium IDE )
Please follow the below steps:
1. Create a Java Project named “Selenium143” in Eclipse IDE as shown below:
2. Configure the above created Project “Selenium143” to work with Selenium RC ( Please refer to Configure Projects in Eclipse IDE to work with Selenium RC)3. Create a Package named “home_page” under the “Selenium143” project as shown below:
4. Create a Java Class named “OpenURL” under the “home_page” package as shown below:
5. Inside the “OpenURL” class, create a method named “openSelenium143” as shown below:

6. Specify  the “openSelenium143” method with @Test annotation as shown below and ensure that an error is displayed:

7. In order to resolve this error, hover your mouse cursor on this error and select ” Import Test (org.junit) ” option as shown below:

8. Ensure that the import org.junit.Test; import statement got added and the error got resolved on import as shown below:

Note: We are importing a predefined class “Test” from “org.junit” package into our “Selenium143” Class. i.e. The functionality of the @Test annotation is predefined in Test Class as part of JUnit framework.

9. As we already know that Selenium RC server  executes our Selenium RC tests on the specified browser,   we’ve to create a Selenium object in our Selenium RC tests to communicate or connect with Selenium RC Server as shown below:

10. After looking at the above screenshot, its very clear that we have an error displayed on adding Selenium object creation statement. Hover your mouse cursor over this error message and select “Import Selenium (com.thoughtworks.selenium) ” option as shown below to resolve the error:

Note: We are importing a predefined class “Selenium” from “com.thoughtworks.selenium” package into our “Selenium143” Class. i.e. We can now use the Selenium Class in our “Selenium143” Class for creating objects and performing operations on the created object.

11. Ensure that the Selenium error got resolved after adding the selected import statement as shown below:

12. But if you have observed correctly , we’ve one more error displayed for ‘DefaultSelenium’ in the above screenshot unresolved. Hover your mouse cover over this error and select “Import DefaultSelenium (com.thoughtworks.selenium) ” option as shown below to resolve this error:

Note: We are importing a predefined class “DefaultSelenium” from “com.thoughtworks.selenium” package into our “Selenium143” Class. i.e. We can now use the DefaultSelenium Class functionality in our “Selenium143” Class.

13. Ensure that the selected import statement got added and also the error got resolved as shown below:

14. Before going to the next steps, lets understand the below statement:

Selenium object1 = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://selenium143.blogspot.com”);

  1. Selenium is a predefined Class
  2. object1 is the object name I have given. In this example object1 is an object of Selenium Class.
  3. new is the java keyword used to create an object for the specified class (i.e. object1 object for Selenium class in this example)
  4. DefaultSelenium( ) is a predefined constructor calling statement.
  5. localhost is the first parameter which gets passed to the DefaulSelenium( ) predefined constructor. This argument is specified as localhost as I’m going to run the Selenium RC test in the same system where I’m writing this code. If you want to run the written Selenium RC test on a different machine, you have to mention the IP Address of the machine on which you want to run this test.
  6. 4444 is the default communication TCP/IP protocol. If you have specified any other protocol say 8888 while starting the Selenium Standalone Server then you have to use 8888 instead of 4444, else if you have not specified any protocol to start the Selenium Standalone Server then you will be using 4444 as this is the default communication protocol. (i.e. If you don’t provide any protocol while starting the Selenium Standalone Server, it will take the default protocol i.e. 4444)
  7. *firefox is the parameter which tells the Selenium Server which browser to use. As we have mentioned it as *firefox it will use Firefox browser to run the Selenium Test. For chrome and IE browsers we have to specify *googlechrome  and *iexplore respectively.
  8. http://selenium143.blogspot.com is the last paramater, which specifies the base URL of the site we are testing.
We can also break the above single statement into two separate statements as shown below:
Selenium object1;    // Declaring the object1 as an instance object of Selenium Class
 
object1 = new DefaultSelenium(“localhost”, 4444, “*firefox”, “http://selenium143.blogspot.com”);   // Assigning the reference to the object1 and calling the DefaultSelenium( ) constructor while the object is getting created.
15. Lets add few more statements inside the openSelenium143( ) method, which uses the ‘object1’ object created by the first statement to 1) starts the Selenium Server Driver in a new Firefox Browser session, 2) open the home page of the base URL specified in the first statement, 3) close the test application and 4) finally to close the Firefox Browser session.
16. First lets start the new Firefox Browser session. Type object1 followed by dot i.e ‘.’ and wait for the selenium commands to appear as shown below:
17. While the selenium commands box is open, type ‘st’ letters and observe that the selenium commands got filtered to four commands from many commands as shown below:

18. Select ‘start( )’ command from the filtered commands as shown below:

19. Ensure that the selected command got added to the code and add a ‘;’ to end the statement as shown below:

20. Save the Selenium RC Test and Run the Test using JUnit as shown below:

21. Ensure that the Test got failed as shown below as we’ve not started the Selenium Standalone Server before running the test using JUnit:

22. Start the Selenium Standalone Server as explained in Start the Selenium Standalone Server and Run the test using JUnit as shown below:

23. Observe that the Firefox has started the  Selenium Server driver as shown below and also observe that the Test got Passed :

24. As we’ve seen in the above steps that object1.start( ); selenium command has opened  Selenium Server Driver which actually Runs the selenium Automation tests in a new Firefox Browser Session, now lets see the   next command which opens the URL of  our Application i.e. object1.open(“http://www.selenium143.blogspot.com”); as shown below:

25. Save and Run the Test using JUnit and observe that the specified URL got opened in Firefox Browser as shown below:

26. Lets write the next command object1.windowMaxmize( ); to maximize the opened Browser as shown below:

27. Save and Run the Test using JUnit and observe that the specified URL got opened in Firefox Browser and the Firefox Browser got maximized as shown below:

28. Lets write the next command object1.close( ); which closes the open Browser having our Application URL as shown below:

29. Save and Run the Test using JUnit and observe that the following Browser Window having the specified URL gets closed as shown below:

30. Lets write the next command object1.stop( ); to stop  the Selenium Server Driver as shown below:

31. Save and Run the Test using JUnit and observe that the Firefox Browser Window which has Selenium Server Driver running gets closed as shown below:

32. As I explained the commands step by step, it will be more clear for you if you can watch the following video of what we have done till the previous step:

Click here to watch the video

33. The selenium commands explained in this post will be used in my next upcoming posts also. So please remember the above commands.

In this post we’ve only used @Test JUnit annotation. We can actually categorize the Selenium Commands used in this post to fall under different JUnit annotations i.e. @Before @Test @After Annotations.

Download this Project:

Click here to download the project used in this post and import into Eclipse IDE on your machine.

Run the Created Selenium RC Test

Run the Created Selenium RC Test

Prerequisites:

1. Create Selenium RC Test as specified in “Create a JUnit Selenium RC Test using Selenium IDE”
2. Start the Selenium Standalone Server as specified in “Start the Selenium Standalone Server”
3. Ensure a Compatible Firefox Browser is Installed on your machine as explained in “Ensure Compatible Firefox Browser is installed”

1. Run the Selenium RC Test

1. In Eclipse IDE, right click on the ‘ImFeelingLucky’ class and select ‘Run As’ -> ‘JUnit Test’ as shown below:

2. See how our automation test runs on Firefox Browser from the below video:

Click here to watch the video

2. Check the Results after the test run is finished

1. After the test run is finished as shown in the above video, we’ve to find out whether the automation test run by selenium RC is passed or failed
2. In order to do that, view the Eclipse IDE after the test run and view the test results as shown below:

3. Red color bar will be displayed instead of Green color bar if the test gets failed.

Thats it !! This is how we run the Selenium RC tests in Eclipse IDE.

%d bloggers like this: