Start SeleniumServer on default port which is 4444:

import org.openqa.selenium.server.SeleniumServer;

public class  Myclass {

public static SeleniumServer server; 

public void startServer() {

server = new SeleniumServer();

// To start the SeleniumServer
server.start();

// To stop the SeleniumServer
server.stop();

}

}

Start SeleniumServer with specific configuration:

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


public class  Myclass {

public static SeleniumServer server;
public static RemoteControlConfiguration rcc;


public void startServer(){

 // Initializing RemoteControlConfiguration and setting to specific port and choosing to execute tests in SingleWindow mode
 rcc = new RemoteControlConfiguation();
 rcc.setPort(5555);
 rcc.setSingleWindow(true);

 // Starting SeleniumServer using the above defined rcc
 server = new SeleniumServer(rcc);

// To start the SeleniumServer
server.start();

// To stop the SeleniumServer
server.stop();
}

}

Using RemoteControlConfiguration, number of parameters can be set for the SeleniumServer like enabling "browser side log" and using "proxy setting mode" etc.

Start SeleniumServer with slowResource mode:


import org.openqa.selenium.server.SeleniumServer;


public class  Myclass {

public static SeleniumServer server;



public void startServer(){


 // The first parameter for the SeleniumServer Constructor is for slowResource mode. Hence making this to true will enable the slowResource mode.
 server = new SeleniumServer(true);

// To start the SeleniumServer
server.start();

// To stop the SeleniumServer
server.stop();
}

}

In slowResource mode the SeleniumServer will executes the commands slowly on the browser, so that we can observe what commands are being executed and where exactly the suite is failing.


Start SeleniumServer with slowResource mode & with RemoteControlConfiguration:

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


public class  Myclass {

public static SeleniumServer server;
public static RemoteControlConfiguration rcc;


public void startServer(){

 // Initializing RemoteControlConfiguration and setting to specific port and choosing to execute tests in SingleWindow mode
 rcc = new RemoteControlConfiguation();
 rcc.setPort(5555);
 rcc.setSingleWindow(true);

 // Starting SeleniumServer using the above defined rcc
 server = new SeleniumServer(true, rcc);

// To start the SeleniumServer
server.start();

// To stop the SeleniumServer
server.stop();
}

}
Share
Related Documents
  1. Automation Testing using Selenium & Java & Junit (1467)
  2. A Developer's Guide to J2EE Solutions (1170)
  3. Java The Complete Reference, Seventh Edition (1385)
  4. [Free] j-hawk : Java basedr performance testing (1350)
  5. GT4 WS Java Core Design (1150)
  6. Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition (1412)
  7. UML for Java Programmers (442)
  8. A Programmer's Guide to Java SCJP Certification: A Comprehensive Primer (3rd Edition) (2137)
  9. Java Network Programming (540)
  10. Automated Web Testing with Selenium for beginners (1128)
  11. Java intro tutorial (313)
  12. JUnit in Action (932)
  13. Essentials of the Java Programming Languag (532)
  14. [Free] Java API Compliance Checker : Tool for compatibility of a Java library API (1421)
  15. Java Tutorial (494)
  16. Introduction to Programming in Java (565)
  17. How to write effective GUI test automation code using Selenium and Java (1167)
  18. JBoss at Work: A Practical Guide (1472)
  19. Java Tester Site (762)
  20. [Ebook] 1000 Java Tips (1657)