Showing posts with label Setting up Selenium RC and TestNG. Show all posts
Showing posts with label Setting up Selenium RC and TestNG. Show all posts

May 21, 2011

Setting up Selenium RC & TestNG using Eclipse - 1

May 21, 2011 7
I found that it is not easy for the beginners to setup Selenium RC and run the GoogleTest.java example after downloading it from www.openqa.org . The purpose of this post is to help beginners (new users to Selenium RC) help setting up Selenium RC with TestNG using Eclipse.


You need eclipse and TestNg Jar files..


Below are the steps to SetUp TestNG in eclipse.


Step1:


Open Eclipse.
Click on Help form Menubar  and select "Install new software".


Step2:


A new window will be opened. Click Add button.
 A new window is opened. and Enter Name as TESTNG and enter site "http://beust.com/eclipse"








Step3:
Select TestNG and Click Next

Step4:

In the next step click finish




Thats it You installed TESTNG in eclipse...

to verify that you need to click on Project -->new -->Other--?>Yoou can see TESTNG foler and expand that folder you cna see TESTNG Class..

See below screen shot..



Then go to second part of the post....it is post regarding 

Setting up Selenium RC & TestNG using Eclipse-II




September 1, 2010

Setting up Selenium RC & TestNG using Eclipse-II

September 01, 2010 26
Setting up Selenium RC & TestNG using Eclipse-II

I found that it is not easy for the beginners to setup Selenium RC and run the GoogleTest.java example after downloading it from www.openqa.org . The purpose of this post is to help beginners (new users to Selenium RC) help setting up Selenium RC with TestNG using Eclipse.
This assumes that you have done the following steps.
Download and install Eclipse (www.eclipse.org)
Download the latest TestNG (www.testng.org)
Download Selenium RC (www.openqa.org)
Install TestNG plugin for eclipse
Please follow the step by step instructions to setup the test environment.
Launch Eclipse, you can setup any directory as your default workspace. For this example, my default workspace is as shown below.
001
Click OK, Eclipse will be launched.


Click File > New
002
Set the project name as Google.
0032
Click Next.
On the Source tab leave the default.
Click on Libraries.
Click on Add External Jars
Add the jar files for TestNG and Selenium RC Java client as shown below.
0042
Click Finish, now you will have a Java project created in Eclipse that is correctly set to use Selenium Client and TestNG jar files.
Now Right Click on the src > New > Class
005 
Name the class file as GoogleTest and Click Finish.
Now create a testng test within GoogleTest class as follows.
006

The next step is to run the Selenium Server as
007
Now Right Click on the test and run this as TestNG test.
008
The test will be successful.
009



You can Start server directly in the TestNG script..


Below is the code for that

import com.thoughtworks.selenium.*;


import org.openqa.selenium.server.*;
import org.testng.annotations.*;




public class GoogleTest {
public Selenium selenium;
public SeleniumServer seleniumserver;


  @BeforeClass
  public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
seleniumserver = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://");
seleniumserver.start();
selenium.start();
}


@Test
public void testgoogle()throws Exception {
  
        selenium.open("http://www.google.com");
        selenium.type("q", "Selenium OpenQA");
        selenium.click("btnG");
        Thread.sleep(10000);
        }
 @AfterClass
 public void tearDown()throws Exception {
    selenium.stop();
    seleniumserver.stop();
    
 }
 }