5.1 Distributed (Grid)
The Selenium grid is a tool for distributing test case scripts, such as testers who often test for multi-browser compatibility, and then use the grid. Here's how to run the same script on multiple browsers.
Files required to use the grid: 1. Selenium server (i.e. Selenium-server-standalone-x.xx.x.jar); 2.grid configuration file (which is responsible for providing host and browser information); 3. Test the script.
First, take a look at the contents of the grid configuration file:
def grid (): d={' http://127.0.0.1:4444/wd/hub ': ' Firefox ', ' Http://127.0.0.1:5555/wd/hub ': ' Internet Explorer ', } return D
The file defines a method that stores a dictionary that assigns 2 different ports to the machine and specifies a different browser (4444 is the default port for the grid hub, and 5555 is a node port, which is described later).
Second, take a look at the test script:
The script is to write a Baidu search keyword and made a simple assertion of the script, the import of Grid_module is the first step in the grid configuration file, the loop body is written from the dictionary to remove the host name and browser name assigned to the following parameters, In this case, the test script will call the local 2 specified browsers and run.
3. Then the server is restarted and the corresponding version of Selenium server is downloaded from http://selenium-release.storage.googleapis.com/index.html:
After downloading it, open cmd, enter Java-jar selenium-server-standalone-x.xx.x.jar-role hub, this is the root of all evils, start it before you can do the things behind. After startup, open a cmd, enter Java-jar selenium-server-standalone-x.xx.x.jar-role node-port 5555, which is the first node to start, specify Port 5555, Consistent with the ports written in the grid configuration file.
When hub and node start up, we enter http://127.0.0.1:4444/grid/console in the browser to open the grid's console:
We can see that a node with a port of 5555 has started up, and the IP here is the native IP.
Python+selenium Automated Software Testing (5th): Selenium gird