Tuesday, 8 January 2013

Code to start and stop Selenium server with eclipse setup

This is the minimum code to start the server and shutdown.


package file;

import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.SeleniumServer;

public class Reset extends SeleneseTestCase {

   private SeleniumServer seleniumServer;
   private Selenium selenium = new DefaultSelenium( "localhost",4444,
            "*chrome","http://");

  public void setUp() throws Exception
      {
          seleniumServer = new SeleniumServer();
          seleniumServer.start();
          selenium.start();
      }


//Test methods shd go here

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

}
Eclipse Configuration

create new project->enter project name->next->libraries->add selenium server.jar and junit-4.8.2.jar and click finish.

Way to export the java program to eclipse IDE.

1)After recording test case,click on options->format->Junit 3
2)Copy the method and paste it in between setup and teardown method.
3)Run->run as Junit

You can see your test case running...Enjoy!!!

No comments:

Post a Comment