Building a selenium distributed environment based on docker

Building a selenium distributed environment based on docker

1. Download the image

docker pull selenium/hub
docker pull selenium/node-firefox
docker pull selenium/node-chrome

Note: selenium/node-firefox and selenium/node-chrome are both headless.

To see the real-time running interface, you need to use one of the following two images.

docker pull selenium/standalone-chrome-debug
docker pull selenium/standalone-firefox-debug

2. Start the Docker of the Hub node

docker run -p 4444:4444 -d --name hub selenium/hub

Parameter Description:

  • run: Run an image and create a container.
  • -p 4444:4444 : Map the port in the container.
  • -d: Run in the background
  • --name: container name, here I will just call this container hub

3. Start the Docker of Node

docker run -P -d --link hub:hub --name firefox selenium/node-firefox
docker run -P -d --link hub:hub --name chrome selenium/node-chrome

Or a Node with a Debug interface

docker run -d -p 5900:5900 --link hub:hub selenium/node-chrome-debug

Parameter Description:

--link is a link to the container with the alias hub.

4. Install and configure VNC

VNC (Virtual Network Console) is the abbreviation of virtual network console. It is an excellent remote control tool software, a free open source software based on UNIX and Linux operating systems, with powerful remote control capabilities, efficient and practical.

Download address: https://www.realvnc.com/en/connect/download/viewer/

5. Test code

To use the Selenium Grid service, you need to use the webdriver.Remote method to connect to the service and pass in the desired_capbilities desired capabilities. The sample script is as follows.

from time import sleep
from selenium import webdriver


driver = webdriver.Remote(
command_executor = 'http://192.168.99.100:4444/wd/hub',
desired_capabilities={'browserName': 'chrome'}
)

driver.get('https://www.baidu.com')
print("start run")
sleep(1)
print(driver.title)
driver.quit()
print("end...")

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Practical way to build selenium grid distributed environment with docker
  • Docker+selenium method to realize automatic health reporting
  • How to use selenium+testng to realize web automation in docker
  • Sample code for testing technology application based on Docker+Selenium Grid

<<:  A brief discussion on Vue3 father-son value transfer

>>:  4 solutions to mysql import csv errors

Recommend

Summary and examples of vue3 component communication methods

The communication modes of vue3 components are as...

Vue implements star rating with decimal points

This article shares the specific code of Vue to i...

mysql5.7.19 zip detailed installation process and configuration

MySQL v5.7.19 official version (32/64 bit install...

Learn MySQL database in one hour (Zhang Guo)

Table of contents 1. Database Overview 1.1 Develo...

Example analysis of MySQL startup and connection methods

Table of contents How to start mysqld Method 1: m...

MySQL master-slave replication principle and practice detailed explanation

Table of contents Introduction effect principle f...

Key points for writing content of HTML web page META tags

The META tag is an auxiliary tag in the head area...

Sample code for batch deployment of Nginx with Ansible

1.1 Copy the nginx installation package and insta...

Summary of the characteristics of SQL mode in MySQL

Preface The SQL mode affects the SQL syntax that ...

How to use vs2019 for Linux remote development

Usually, there are two options when we develop Li...

Detailed steps for using AES.js in Vue

Use of AES encryption Data transmission encryptio...

Example analysis of the page splitting principle of MySQL clustered index

This article uses an example to illustrate the pa...

5 commonly used objects in JavaScript

Table of contents 1. JavaScript Objects 1).Array ...