Configurando a sua

Instructions, step by step, showing how to run a simple Selenium Grid.

Page being translated from English to Portuguese. Do you speak Portuguese? Help us to translate it by sending us pull requests!

Grid roles

Several components compose a Selenium Grid. Depending on your needs, you can start each one of them on its own, or a few at the same time by using a Grid role.

Standalone

Standalone is the union of all components, and to the user’s eyes, they are executed as one. A fully functional Grid of one is available after starting it in the Standalone mode.

Standalone is also the easiest mode to spin up a Selenium Grid. By default, the server will be listening on http://localhost:4444, and that’s the URL you should point your RemoteWebDriver tests. The server will detect the available drivers that it can use from the System PATH.

java -jar selenium-server-<version>.jar standalone

Hub and Node(s)

It enables the classic Hub & Node(s) setup. These roles are suitable for small and middle-sized Grids.

Hub

A Hub is the union of the following components:

  • Router
  • Distributor
  • Session Map
  • New Session Queue
  • Event Bus
java -jar selenium-server-<version>.jar hub

By default, the server will be listening on http://localhost:4444, and that’s the URL you should point your RemoteWebDriver tests.

Node(s)

One or more Nodes can be started in this setup, and the server will detect the available drivers that it can use from the System PATH.

java -jar selenium-server-<version>.jar node

Distributed

On Distributed mode, each component needs to be started on its own. This setup is more suitable for large Grids.

  1. Event Bus: serve como um caminho de comunicação para outros componentes da rede nas etapas subsequentes.
java -jar selenium-server-<version>.jar  event-bus
  1. Session Map: responsável por mapear os IDs da sessão para o nó em que a sessão está sendo executada:
java -jar selenium-server-<version>.jar sessions
  1. New Session Queue: Inicie o novo enfileirador de sessão, ele adiciona a nova solicitação de sessão a uma fila local. O distribuidor atende o pedido da fila.
java -jar selenium-server-<version>.jar sessionqueue
  1. Distributor: Nodes register to it, and assigns a Node for a session request.
java -jar selenium-server-<version>.jar distributor --sessions http://localhost:5556 --sessionqueue http://localhost:5559 --bind-bus false
  1. Router: the Grid entrypoint, in charge of redirecting requests to the right component.
java -jar selenium-server-<version>.jar router --sessions http://localhost:5556 --distributor http://localhost:5553 --sessionqueue http://localhost:5559
  1. Node(s)
java -jar selenium-server-<version>.jar node 

Querying Selenium Grid

After starting a Grid, there are mainly two ways of querying its status, through the Grid UI or via an API call.

The Grid UI can be reached by opening your preferred browser and heading to http://localhost:4444.

API calls can be done through the http://localhost:4444/status endpoint or using GraphQL:

curl -X POST -H "Content-Type: application/json" --data '{ "query": "{grid{uri}}" }' -s http://localhost:4444/graphql | jq .

For simplicity, all command examples shown in this page assume that components are running locally. More detailed examples and usages can be found in the Configuring Components section.

Aviso

A Selenium Grid deve ser protegida do acesso externo usando permissões de firewall.

A falha em proteger sua rede pode resultar em um ou mais dos seguintes eventos:

  • Você fornece acesso aberto à sua infraestrutura de rede
  • Você permite que terceiros acessem aplicativos e arquivos internos da web
  • Você permite que terceiros executem binários personalizados

Veja esta postagem do blog em Detectify, que dá uma boa visão geral de como uma rede exposta publicamente pode ser mal utilizada: Não deixe sua grade totalmente aberta.

Última modificação October 19, 2021: Updated translation for PT-BR (#807)[deploy site] (0a15bd7)