Thursday, 18 July 2013

Start Selenium RC Server Within Code.


Now there is no need to start selenium server by going to command prompt and calling to server.

You can directly start the server in your script itself.
You just need to import
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;

The code will look like -

import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;

public class tet extends SeleneseTestCase {
private Selenium selenium;
public SeleniumServer seleniumserver;


@Before
public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
seleniumserver = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "https://www.google.co.in/");
seleniumserver.start();
selenium.start();
}