Selenium Webdriver Study Summary-selenium Grid & Webdriver (ix)

Source: Internet
Author: User
Tags selenium grid


QQ Group: 136924235

Forum: http://bbs.shareku.com

Google Tutorial : Https://code.google.com/p/selenium/wiki/Grid2

Hub/node

System requirements: JDK, Firefox, Chrome, InternetExplorer

Tools Required: Selenium-server-standalone-xxx.jar

: http://code.google.com/p/selenium/downloads/list

Start Hub

ip:192.168.0.22

command line to start the hub:

C:\>java-jare:\selenium-server-standalone-2.37.0.jar–role Hub–port 4444

Optional Parameters:

L-port (default 4444) is the default hub server (jetty) port of 4444, and after the service is started, the grid Co can be accessed through http://localhost:4444/grid/console Nsole View the status of each node

L-timeout (default), when a node does not receive any request at a specified time, the node is freed to join the other queue, allowing the client not to remain in the suspended state

L-maxsession (default 5), the maximum number of browsers running in the node, which differs from the maxinstance of the browser in the node

The first is the maximum number of browsers, the same version of the browser Max instances

To configure the hub with JSON:

C:\>java-jar selenium-server-standalone-2.37.0.jar-role hub-hubconfig Hubconfig.json

Hubconfig.json as follows:

{

"Host": null,

"Port": 4444,

"Newsessionwaittimeout":-1,

"Servlets": [],

"Prioritizer": null,

"Capabilitymatcher": "Org.openqa.grid.internal.utils.DefaultCapabilityMatcher",

"Throwoncapabilitynotpresent": true,

"Nodepolling": 5000,

"Cleanupcycle": 5000,

"Timeout": 60,

"Browsertimeout": 60,

"Maxsession": 5,

"Jettymaxthreads":-1

}

Configuration timeout:

To maintain the integrity of the test run, two additional timeout settings are provided in the grid, as follows:

-timeout: Units (seconds), specified in the start hub command line parameter, when the client crashes for a specified time, the grid reclaims all resources

-browsertimeout: Units (seconds), specified in the start hub command line parameter, when the node browser is in a pending state for a specified time, the grid reclaims all resources

Note:in the Webdriver API, Webdriver.manage (). Timeouts () sets the timeout for different operations to take effect in the grid as well;

After configuring two parameter values in the hub, it will take effect for all node, but can also be configured locally on node (not recommended by the official);

For browsertimeout should be higher than the socket lock timeout (s), in addition, since the timeout is the last line of defense, it should also be higher than webdriver.manage (). Timeouts () specified time-out

Start Node

ip:192.168.0.143

Command line start node:

C:\>java-jar e:\selenium-server-standalone-2.30.0.jar-role Node–hub Http://192.168.0.22:4444/grid/register

Note: By default, Node The default port is 5555 ;

-hub parameter specifies Grid Hub the address of the receiving node registration;

for compatibility Selenium1.0 , -role the value of the parameter can be used ( WD/RC ) , when using node can accept Webdriver and the RC connection examples for both

Command Line configuration node:

By default, the grid launches 11 browser instances, 5 Firefox, 5 Chrome, 1 Internet Explorer, and the maximum number of concurrent execution tests is 5.

We can change the default configuration about the browser by configuring the-browser parameter, and once the change will overwrite the default configuration

Example_1: The following configuration will launch 5 Firefox3.6 instances in a Linux environment
-Browser browsername=Firefox,version=3.6,maxinstances  =5,platform=LINUX
Example_2: If your remote machine has multiple versions of Firefox or another browser, you can use the following configuration
-browser browsername=firefox,version=4,firefox_binary=/home/myhomedir/firefox4/firefox,maxinstances=4,platform= Linux
Note: If the parameters in the value The string contains spaces, and you can wrap the string with double quotes. 

To configure a node with JSON:

C:\>java-jar E:\selenium-server-standalone-2.30.0.jar-role Node-nodeconfige:\selenium\node.json

Node.json as follows:

{

"Capabilities": [

{

"Browsername": "Firefox",

"Maxinstances": 2, Maximum number of browser instantiations in the current version

"Seleniumprotocol": "Webdriver"

},

{

"Browsername": "Internet Explorer",

"Maxinstances": 1,

"Seleniumprotocol": "Webdriver"

}

],

"Configuration":

{

"Proxy": "Org.openqa.grid.selenium.proxy.DefaultRemoteProxy",

"Maxsession": 2, test tasks for maximum parallel execution

"Port": 5555,

"Host": 192.168.0.143,

"Register": True,

"Registercycle": the node to Hub frequency of issuance of registration requests, per millisecond Ms

"Hubport": 4444,

"Hubhost": 192.168.0.22

}

}


Use Grid Run Tests

For Webdriver, you need to use Remotewebdriver and Desiredcapabilities objects to define what platform you are going to run your tests on, such as browsers, browser versions, operating systems, and the like below

Desiredcapabilities capability =desiredcapabilities.firefox ();

Capability.setbrowsername ("Firefox");

Capability.setplatform ("LINUX");

Capability.setversion ("3.6");

Webdriver Driver = new Remotewebdriver (Newurl ("Http://localhost:4444/wd/hub"), capability);

The above script will match the nodes configured below

-browser Browsername=firefox,version=3.6,platform=linux

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.