How testers build SELENIUM-GRID2 environments (see Java)

Source: Internet
Author: User

Selenium is very helpful for our web automation testing, if we want to carry out a wide range of test coverage, we can not only run on one or two machines, the same selenium-grid also provide us with such help, We can easily build a distributed test environment with Selenium-grid. Unlike some of the other common distributed programs "such as: Hudson", Selenium-grid is an automated distributed testing solution specifically for Selenium.

The advantages are:

    • Rapid setup of distribution Environment "with simple parameter Configuration"
    • Automatically assign test scripts "for different Environments"
    • Only one Test code "target test machine does not need to have test code"

Build SELENIUM2 Environment

Before setting up the Selenium-grid, the first thing to do is to set up the selenium environment on each test machine "the exact point should be the environment of the agent node". Here's an example of Java:

    1. Install Java "Download"
    2. Configure the Java environment variable "here"
    3. Download IE, chrome driver program "If you want to test other browsers also need additional download; FF driver default in Webdriver, no download Required"
    4. Put IE, Chrome's driver program into the system environment variable "For example: System32"
    5. Install the latest version of the browser "FF, chrome, etc."
    6. Download Selenium webdriver "Download standalone server"
    7. Code testing

Local version:

[Java]View PlainCopy
  1. Import org.openqa.selenium.*;
  2. Import org.openqa.selenium.firefox.*;
  3. Import org.openqa.selenium.chrome.*;
  4. Import org.openqa.selenium.htmlunit.*;
  5. Import org.openqa.selenium.ie.*;
  6. Webdriver Driver = new Chromedriver ();
  7. Webdriver Driver = new Firefoxdriver ();
  8. Webdriver Driver = new Htmlunitdriver ();
  9. Webdriver Driver = new Internetexplorerdriver ();
  10. Driver.get ("http://www.dangdang.com");
  11. System.out.println (Driver.getcurrenturl ());
  12. Driver.quit ();

Remote version:

[Java]View PlainCopy
    1. Import org.openqa.selenium.*;
    2. Import org.openqa.selenium.remote.DesiredCapabilities;
    3. Import Org.openqa.selenium.remote.RemoteWebDriver;
    4. Desiredcapabilities Ffdesiredcap = Desiredcapabilities.firefox ();
    5. Desiredcapabilities Chromedesiredcap = Desiredcapabilities.chrome ();
    6. Desiredcapabilities Iedesiredcap = Desiredcapabilities.internetexplorer ();
    7. Webdriver WD = new Remotewebdriver (New URL ("Http://localhost:4444/wd/hub"), Iedesiredcap);
    8. Wd.get ("http://www.google.com");
    9. Thread.Sleep (1200);
    10. System.out.println (Wd.getcurrenturl ());
    11. Wd.quit ();

All of these tests have been successful, which means that your environment has been successfully set up and you can build SELENIUM2 environments on multiple systems and platforms in turn.

Note:

If you use the IDE to refer to the Selenium-standalone-server Jar package to project build path, you must specify the path to the jar package if it is compiled and executed directly from the command line, or the compilation will fail.

[Java]View PlainCopy
    1. Javac-classpath $HOME/path/to/selenium-server.jar Test.java
    2. Java-classpath $HOME/path/to/selenium-server.jar Test

Build Selenium-grid Environment

When the SELENIUM2 environment on all the test machines is successfully built, you can start the SELENIUM-GRID2 environment.

start a hubfirst:

[Java]View PlainCopy
    1. Java-jar Selenium-server-standalone-x.xx.x.jar-role Hub

The machine that starts the hub is not a test machine, and any machine with a Java environment can. This is the central node of the entire Selenium-grid, and all the remote tests are forwarded by it and then tested on the corresponding test machine.

To start the test agent node:

[Java]View PlainCopy
    1. Java-jar selenium-server-standalone-x.xx.x.jar-role Node

The test agent must start on the test machine "on the machine where the SELENIUM2 environment was built", and its registered address must be the IP and port of the machine on which the hub resides. Multiple agents can be started on a single test machine, provided that the same port is not used. "Of course it is not recommended to do so as far as possible to avoid destabilizing factors"

View Selenium-grid Status

When the hub and all the agent nodes are successful, you can view the status of the current Selenium-grid through the browser and access the address http://localhost:4444/grid/console directly. You can see that the page shows the number and type of proxy nodes that can support testing, and the number and types shown here are related to the configuration parameters that you brought when you started the agent node. When the agent node is started is a registration process, the parameters taken at startup are remembered as registration information by the hub, so the information that is seen on the page is a summary of the information that each agent node registers.

Article transferred from Sina blog (wind-like Freedom): http://blog.csdn.net/five3/article/details/9671287

How testers build SELENIUM-GRID2 environments (see Java)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.