September 1, 2010

September 01, 2010 3
Hi all,
I am adit, friend of naga(colleague too)!A great news in the first post! I am recently tansformed from tester to developer(cheers to meeeeeeee). There are a couple of projects that I am working , but for now I will do my best to help you all learn PHP(server-side scripting language). I will start from scratch so that each and everybody can follow and learn(and become a master). Hope you guys like this blog!!!!!lets Rock PHP @ http://testerinyou.blogspot.com/

Tester then,Developer now
adit

Setting up Selenium RC & TestNG using Eclipse-II

September 01, 2010 25
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();
    
 }
 }