Header Ads

How To Start And Stop Selenium Server From Eclipse

Here is a post to let you know how to start and stop selenium server through java via Eclipse.This is important when you are running your test in modular driven approach.In modular driven approach we will divide the test into several  small modules.

This small code will start selenium server..


private SeleniumServer server = null;

 
      public void startSeleniumServer() {
      if (server == null) {
            try {
                  server = new SeleniumServer();
            } catch (Exception e) {
System.err.println("Could not create Selenium Server because of: " + e.getMessage());
                  e.printStackTrace();
            }
            }
            try {
                  server.start();
            } catch (Exception e) {
System.err.println("Could not start Selenium Server because of: "   + e.getMessage());
                  e.printStackTrace();
            }
      }
Let us write a code as per modular driven approach to stop Selenium Server
public void stopSeleniumServer() {
            if (server != null) {
                  try {
                        server.stop();
                        server = null;
                  } catch (Exception e) {
System.err.println("Could not stop Selenium Server because of: "  + e.getMessage());
                  e.printStackTrace();
                  }
            }

Hope you like this post . Please let me know about thought on this. Please post your comment below.
Powered by Blogger.