. NET Automation Test tool: Selenium Grid

Source: Internet
Author: User
Tags install node seleniumhq selenium grid

In the production environment, QA will run dozens of hundred test case at the same time. If you use a single machine serial, it is a very time-consuming thing, estimated than the hand point is not much faster. With parallel scenarios, there are two ways to write your own parallel framework, one to use a ready-made selenium Grid.

Write your own parallel framework, the advantage is that everything is in control, there are problems can be quickly targeted to the business of a high degree of customization, user convenience. At the moment, the question is, if a single multi-account login to the same system, will not be a string of cookies? However, I have found that it is possible that browser vendors have isolated different driver instances, which saves a lot of things. The implementation idea is basically: each client (the parser of the test script) sends the TESTCASE message to the MQ queue, and multiple actuators listen for the same queue consumption message, execute the test case, and return the result.

Because of their laziness, this is done in parallel with a ready-made selenium grid. Seleniumgrid is a cluster that has a central node, called a hub, and multiple execution nodes, called node. The role of the hub is to manage nodes (such as node information, whether alive), establish a connection with the client, and send execution commands to each node. The demarcation point between the client and the hub is driver here. That is, the selenium script runs on the client, but the control driver is inside the grid. (This is actually different from the boundaries of your own parallel frame.) The following is a door, introduce the installation, operation, Helloworld (oh, it should be hello Baidu ...) )

1. Download:

1.Selenium Standalone server:http://www.seleniumhq.org/download/

  

2. Various driver. The entrance can also be found in Www.seleniumhq.org/download.

  

Chromedriver Direct access to: https://sites.google.com/a/chromium.org/chromedriver/

2. Installation:

1. Find two machines, virtual machines can also. I use the a:10.189.1.206,b:10.189.1.201 here. A as hub,b as node

2. Install the hub: put the downloaded Selenium-server-standalone-3.5.2.jar on the A machine, run the command:

Java-jar Selenium-server-standalone-3.5.2.jar-role Hub

  

3. Install node: Similarly, put the downloaded Selenium-server-standalone-3.5.2.jar on the B machine and run the command:

Java-jar selenium-server-standalone-3.5.2.jar-role node-port 6666-hub http://10.189.1.206:4444/grid/register

The address of the hub must be specified here, and the port number (port) can be set or not. After execution, the hub interface is as follows, indicating that the hub has accepted node's registration:

  

can access the console of the entire grid: http://10.189.1.206:4444/grid/console/

  

4. Install Chromedriver on hub and node:

Copy the downloaded Chromedriver.exe to the A machine, for example in the C:\SeleniumPlugins directory. In the path of the environment variable, add the directory address: C:\SeleniumPlugins.

On the B machine, perform the same operation.

    

3. C # code:

1. Create the console project and add the selenium reference.

  

2. Code:

Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; Using openqa.selenium;using openqa.selenium.remote;using openqa.selenium.chrome;namespace RunTestOnRemoteGrid{    Class    Program {        static void Main (string[] args)        {            iwebdriver driver=new chromedriver ();            Try            {                driver = new Remotewebdriver (New Uri ("Http://10.189.1.206:4444/wd/hub"), New Chromeoptions ());                Driver. Navigate (). Gotourl ("http://www.baidu.com");            }            catch (Exception ex)            {                Console.WriteLine (ex. ToString ());               }            Finally            {                driver. Quit ();}}}    

3. Run: You can see the client side in the execution, no action, and B machine, open the Chrome browser, access to Baidu

. NET Automation Test tool: Selenium Grid

Related Article

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.