|
1 | 1 | ---
|
2 |
| -title: "Customizing a Node" |
3 |
| -linkTitle: "Customize Node" |
| 2 | +title: "Personalizando um Nó" |
| 3 | +linkTitle: "Personalizando um Nó" |
4 | 4 | weight: 4
|
5 | 5 | ---
|
| 6 | +## Como personalizar um Nó |
6 | 7 |
|
7 |
| -{{% pageinfo color="warning" %}} |
8 |
| -<p class="lead"> |
9 |
| - <i class="fas fa-language d-4"></i> |
10 |
| - Page being translated from |
11 |
| - English to Portugese. Do you speak Portugese? Help us to translate |
12 |
| - it by sending us pull requests! |
13 |
| -</p> |
14 |
| -{{% /pageinfo %}} |
| 8 | +Há momentos em que gostaríamos de personalizar um Nó de acordo com nossas necessidades. |
15 | 9 |
|
16 |
| -## How to customize a Node |
| 10 | +Por exemplo, podemos desejar fazer alguma configuração adicional antes que uma sessão comece a ser executada e executar alguma limpeza após o término de uma sessão. |
17 | 11 |
|
18 |
| -There are times when we would like a Node to be customized to our needs. |
| 12 | +Os seguintes passos podem ser seguidos para isso: |
19 | 13 |
|
20 |
| -For e.g., we may like to do some additional setup before a session begins execution and some clean-up after a session runs to completion. |
21 |
| - |
22 |
| -Following steps can be followed for this: |
23 |
| - |
24 |
| -* Create a class that extends `org.openqa.selenium.grid.node.Node` |
25 |
| -* Add a static method (this will be our factory method) to the newly created class whose signature looks like this: |
| 14 | +- Crie uma classe que estenda `org.openqa.selenium.grid.node.Node`. |
| 15 | +- Adicione um método estático (este será nosso método de fábrica) à classe recém-criada, cuja assinatura se parece com esta: |
26 | 16 |
|
27 | 17 | `public static Node create(Config config)`. Here:
|
28 | 18 |
|
29 |
| - * `Node` is of type `org.openqa.selenium.grid.node.Node` |
30 |
| - * `Config` is of type `org.openqa.selenium.grid.config.Config` |
31 |
| -* Within this factory method, include logic for creating your new Class. |
32 |
| -* To wire in this new customized logic into the hub, start the node and pass in the fully qualified class name of the above class to the argument `--node-implementation` |
| 19 | + * `Node` é do tipo `org.openqa.selenium.grid.node.Node` |
| 20 | + * `Config` é do tipo `org.openqa.selenium.grid.config.Config` |
| 21 | +* Dentro deste método de fábrica, inclua a lógica para criar sua nova classe.. |
| 22 | +* TPara incorporar esta nova lógica personalizada no hub, inicie o nó e passe o nome da classe totalmente qualificado da classe acima como argumento. `--node-implementation` |
33 | 23 |
|
34 |
| -Let's see an example of all this: |
| 24 | +Vamos ver um exemplo de tudo isso: |
35 | 25 |
|
36 |
| -### Custom Node as an uber jar |
| 26 | +### Node personalizado como um uber jar |
37 | 27 |
|
38 |
| -1. Create a sample project using your favourite build tool (**Maven**|**Gradle**). |
39 |
| -2. Add the below dependency to your sample project. |
| 28 | +1. Crie um projeto de exemplo usando sua ferramenta de construção favorita. (**Maven**|**Gradle**). |
| 29 | +2. Adicione a seguinte dependência ao seu projeto de exemplo.. |
40 | 30 | * [org.seleniumhq.selenium/selenium-grid](https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-grid)
|
41 |
| -3. Add your customized Node to the project. |
42 |
| -4. Build an [uber jar](https://imagej.net/develop/uber-jars) to be able to start the Node using `java -jar` command. |
43 |
| -5. Now start the Node using the command: |
| 31 | +3. Adicione o seu nó personalizado ao projeto. |
| 32 | +4. Construir algo. [uber jar](https://imagej.net/develop/uber-jars) Para ser capaz de iniciar o Node usando o comando `java -jar`. |
| 33 | +5. Agora inicie o nó usando o comando: |
44 | 34 |
|
45 | 35 | ```bash
|
46 | 36 | java -jar custom_node-server.jar node \
|
47 | 37 | --node-implementation org.seleniumhq.samples.DecoratedLoggingNode
|
48 | 38 | ```
|
| 39 | +**Observação:** Se estiver usando o Maven como ferramenta de construção, é preferível usar o [maven-shade-plugin](https://maven.apache.org/plugins/maven-shade-plugin) em vez do [maven-assembly-plugin](https://maven.apache.org/plugins/maven-assembly-plugin) porque o plugin maven-assembly parece ter problemas para mesclar vários arquivos de Service Provider Interface (`META-INF/services`). |
49 | 40 |
|
50 |
| -**Note:** If you are using Maven as a build tool, please prefer using [maven-shade-plugin](https://maven.apache.org/plugins/maven-shade-plugin) instead of [maven-assembly-plugin](https://maven.apache.org/plugins/maven-assembly-plugin) because maven-assembly plugin seems to have issues with being able to merge multiple Service Provider Interface files (`META-INF/services`) |
51 | 41 |
|
52 |
| -### Custom Node as a regular jar |
| 42 | +### Node personalizado como jar |
| 43 | + |
| 44 | +1. Crie um projeto de exemplo usando a sua ferramenta de construção favorita (**Maven**|**Gradle**). |
| 45 | +2. Adicione a seguinte dependência ao seu projeto de exemplo: |
| 46 | + * [org.seleniumhq.selenium/selenium-grid](https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-grid) |
| 47 | +3. Adicione o seu Node personalizado ao projeto. |
| 48 | +4. Construa um arquivo JAR do seu projeto usando a sua ferramenta de construção. |
| 49 | +5. Agora, inicie o Node usando o seguinte comando: |
53 | 50 |
|
54 |
| -1. Create a sample project using your favourite build tool (**Maven**|**Gradle**). |
55 |
| -2. Add the below dependency to your sample project. |
56 |
| - * [org.seleniumhq.selenium/selenium-grid](https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-grid) |
57 |
| -3. Add your customized Node to the project. |
58 |
| -4. Build a jar of your project using your build tool. |
59 |
| -5. Now start the Node using the command: |
60 | 51 |
|
61 | 52 | ```bash
|
62 | 53 | java -jar selenium-server-4.6.0.jar \
|
63 | 54 | --ext custom_node-1.0-SNAPSHOT.jar node \
|
64 | 55 | --node-implementation org.seleniumhq.samples.DecoratedLoggingNode
|
65 | 56 | ```
|
66 |
| -Below is a sample that just prints some messages on to the console whenever there's an activity of interest (session created, session deleted, a webdriver command executed etc.,) on the Node. |
67 |
| - |
| 57 | +Aqui está um exemplo que apenas imprime algumas mensagens no console sempre que houver uma atividade de interesse (sessão criada, sessão excluída, execução de um comando do webdriver, etc.) no Node. |
68 | 58 |
|
69 | 59 | <details>
|
70 | 60 | <summary>Sample customized node</summary>
|
@@ -234,21 +224,21 @@ public class DecoratedLoggingNode extends Node {
|
234 | 224 | ```
|
235 | 225 | </details>
|
236 | 226 |
|
237 |
| -**_Foot Notes:_** |
| 227 | +**_Notas de Rodapé:_** |
238 | 228 |
|
239 |
| -In the above example, the line `Node node = LocalNodeFactory.create(config);` explicitly creates a `LocalNode`. |
| 229 | +No exemplo acima, a linha `Node node = LocalNodeFactory.create(config);` cria explicitamente um `LocalNode`. |
240 | 230 |
|
241 |
| -There are basically 2 types of *user facing implementations* of `org.openqa.selenium.grid.node.Node` available. |
| 231 | +Basicamente, existem 2 tipos de implementações *visíveis para o usuário* de `org.openqa.selenium.grid.node.Node` disponíveis. |
242 | 232 |
|
243 |
| -These classes are good starting points to learn how to build a custom Node and also to learn the internals of a Node. |
| 233 | +Essas classes são bons pontos de partida para aprender como criar um Node personalizado e também para compreender os detalhes internos de um Node. |
244 | 234 |
|
245 |
| -* `org.openqa.selenium.grid.node.local.LocalNode` - Used to represent a long running Node and is the default implementation that gets wired in when you start a `node`. |
246 |
| - * It can be created by calling `LocalNodeFactory.create(config);`, where: |
247 |
| - * `LocalNodeFactory` belongs to `org.openqa.selenium.grid.node.local` |
248 |
| - * `Config` belongs to `org.openqa.selenium.grid.config` |
249 |
| -* `org.openqa.selenium.grid.node.k8s.OneShotNode` - This is a special reference implementation wherein the Node gracefully shuts itself down after servicing one test session. This class is currently not available as part of any pre-built maven artifact. |
250 |
| - * You can refer to the source code [here](https://github.com/SeleniumHQ/selenium/blob/trunk/java/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java) to understand its internals. |
251 |
| - * To build it locally refer [here](https://github.com/SeleniumHQ/selenium/blob/trunk/deploys/k8s/README.md). |
252 |
| - * It can be created by calling `OneShotNode.create(config)`, where: |
253 |
| - * `OneShotNode` belongs to `org.openqa.selenium.grid.node.k8s` |
254 |
| - * `Config` belongs to `org.openqa.selenium.grid.config` |
| 235 | +* `org.openqa.selenium.grid.node.local.LocalNode` - Usado para representar um Node de execução contínua e é a implementação padrão que é usada quando você inicia um `node`. |
| 236 | + * Pode ser criado chamando `LocalNodeFactory.create(config);`, onde: |
| 237 | + * `LocalNodeFactory` pertence a `org.openqa.selenium.grid.node.local` |
| 238 | + * `Config` pertence a `org.openqa.selenium.grid.config` |
| 239 | +* `org.openqa.selenium.grid.node.k8s.OneShotNode` - Esta é uma implementação de referência especial em que o Node encerra-se graciosamente após atender a uma sessão de teste. Esta classe atualmente não está disponível como parte de nenhum artefato Maven pré-construído. |
| 240 | + * Você pode consultar o código-fonte [aqui](https://github.com/SeleniumHQ/selenium/blob/trunk/java/src/org/openqa/selenium/grid/node/k8s/OneShotNode.java) para entender seus detalhes internos. |
| 241 | + * Para construí-lo localmente, consulte [aqui](https://github.com/SeleniumHQ/selenium/blob/trunk/deploys/k8s/README.md). |
| 242 | + * Pode ser criado chamando `OneShotNode.create(config)`, onde: |
| 243 | + * `OneShotNode` pertence a `org.openqa.selenium.grid.node.k8s` |
| 244 | + * `Config` pertence a `org.openqa.selenium.grid.config` |
0 commit comments