Skip to content

Commit 340ef4d

Browse files
Do the requested changes
1. BeforeAll and AfterAll functions removed. 2. Print statements removed. 3. driver.manage().window().maximize() removed. 4. Driver navigation and implicit wait code moved into test body. 5. Markdown changes done in all the 4 languages.
1 parent 158ba8c commit 340ef4d

File tree

5 files changed

+86
-71
lines changed

5 files changed

+86
-71
lines changed

examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
import java.time.Duration;
66

7-
import org.junit.jupiter.api.AfterAll;
87
import org.junit.jupiter.api.AfterEach;
9-
import org.junit.jupiter.api.BeforeAll;
108
import org.junit.jupiter.api.BeforeEach;
119
import org.junit.jupiter.api.Test;
1210
import org.openqa.selenium.By;
@@ -18,24 +16,17 @@ public class UsingSeleniumTest {
1816

1917
WebDriver driver;
2018

21-
@BeforeAll
22-
public static void beforeAll() {
23-
System.out.println("This method will be executed only once before all the tests.");
24-
}
25-
2619
@BeforeEach
2720
public void setup() {
28-
System.out.println(
29-
" This method will be executed before each test, so here write the common code that has to be executed.");
3021
driver = new ChromeDriver();
31-
driver.manage().window().maximize();
32-
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
33-
driver.get("https://www.selenium.dev/selenium/web/web-form.html");
3422
}
3523

3624
@Test
3725
public void eightComponents() {
3826

27+
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
28+
driver.get("https://www.selenium.dev/selenium/web/web-form.html");
29+
3930
String title = driver.getTitle();
4031
assertEquals("Web form", title);
4132

@@ -53,13 +44,7 @@ public void eightComponents() {
5344

5445
@AfterEach
5546
public void teardown() {
56-
System.out.println(" This method will be executed after each test, so here write the clean up code.");
5747
driver.quit();
5848
}
5949

60-
@AfterAll
61-
public static void afterAll() {
62-
System.out.println("This method will be executed only once after all the tests.");
63-
}
64-
6550
}

website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,9 @@ In your project's `package.json`, add requirement to `dependencies`:
138138

139139
### Asserting
140140

141-
Assertions are very important part of Selenium, as they determine whether the state
142-
of the application is same what we are expecting or not. If the assertion fails,
143-
then the test case is failed and execution is stopped.
144141
{{< tabpane text=true >}}
145142
{{< tab header="Java" >}}
146-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L39-L40" >}}
143+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L30-L31" >}}
147144
{{< /tab >}}
148145
{{% tab header="Python" %}}
149146
{{< badge-code >}}
@@ -169,11 +166,11 @@ then the test case is failed and execution is stopped.
169166

170167
### Set Up
171168

172-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L20-L35" >}}
169+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L19-L22" >}}
173170

174171
### Tear Down
175172

176-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L53-L64" >}}
173+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L45-L48" >}}
177174

178175
{{% /tab %}}
179176
{{% tab header="Python" %}}

website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,9 @@ In your project's `package.json`, add requirement to `dependencies`:
134134

135135
### Asserting
136136

137-
Assertions are very important part of Selenium, as they determine whether the state
138-
of the application is same what we are expecting or not. If the assertion fails,
139-
then the test case is failed and execution is stopped.
140137
{{< tabpane text=true >}}
141138
{{< tab header="Java" >}}
142-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L39-L40" >}}
139+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L30-L31" >}}
143140
{{< /tab >}}
144141
{{% tab header="Python" %}}
145142
{{< badge-code >}}
@@ -165,11 +162,11 @@ then the test case is failed and execution is stopped.
165162

166163
### Set Up
167164

168-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L20-L35" >}}
165+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L19-L22" >}}
169166

170167
### Tear Down
171168

172-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L53-L64" >}}
169+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L45-L48" >}}
173170

174171
{{% /tab %}}
175172
{{% tab header="Python" %}}

website_and_docs/content/documentation/webdriver/getting_started/using_selenium.pt-br.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ title: "Organizando e executando o código Selenium"
33
linkTitle: "Utilizando o Selenium"
44
weight: 10
55
description: >
6-
Escalonamento da execução do Selenium com um IDE e uma biblioteca do Test Runner
6+
Escalonamento da execução do Selenium com um IDE e uma biblioteca do Test Runner
77
---
88

9-
Se quiser executar mais do que um punhado de scripts pontuais, precisa de
9+
Se quiser executar mais do que um punhado de scripts pontuais, precisa de
1010
ser capaz de organizar e trabalhar com seu código. Esta página deve dar a você
1111
ideias de como fazer coisas produtivas com seu código Selenium.
1212

1313
## Usos comuns
1414

15-
A maioria das pessoas usa o Selenium para executar testes automatizados para aplicações web,
15+
A maioria das pessoas usa o Selenium para executar testes automatizados para aplicações web,
1616
mas o Selenium suporta qualquer caso de uso de automação de navegador.
1717

1818
### Tarefas Repetitivas
@@ -32,10 +32,9 @@ Executar o Selenium para testes requer fazer asserções sobre as ações tomada
3232
Então uma boa biblioteca de asserções é necessária. Características adicionais para prover estrutura para testes
3333
requerem o uso de [Test Runner] (#test-runners).
3434

35-
3635
## IDEs
3736

38-
Independentemente de como você usa o código do Selenium,
37+
Independentemente de como você usa o código do Selenium,
3938
não será muito eficaz escrevendo ou executando-o sem um bom
4039
ambiente de desenvolvimento integrado. Aqui estão algumas opções comuns...
4140

@@ -50,10 +49,11 @@ ambiente de desenvolvimento integrado. Aqui estão algumas opções comuns...
5049
## Executador de teste
5150

5251
Mesmo que não esteja a usar o Selenium para testes, se tiver casos de uso avançado, pode fazer
53-
sentido usar um executor de testes para organizar melhor seu código. Ser capaz de usar hooks antes/depois
52+
sentido usar um executor de testes para organizar melhor seu código. Ser capaz de usar hooks antes/depois
5453
e executar coisas em grupos ou em paralelo pode ser muito útil.
5554

5655
### Escolhendo
56+
5757
Há muitos executores de teste diferentes disponíveis.
5858

5959
Todos os exemplos de código nesta documentação podem ser encontrados em (ou estão sendo movidos para) nossos diretórios
@@ -63,36 +63,40 @@ que será usado para todos os exemplos nesta página.
6363

6464
{{< tabpane text=true >}}
6565
{{% tab header="Java" %}}
66+
6667
- [JUnit](https://junit.org/junit5/) - Uma estrutura de teste amplamente utilizada para testes Selenium baseados em Java.
6768
- [TestNG](https://testng.org/) - Oferece recursos extras, como execução de testes paralelos e testes parametrizados.
68-
{{% /tab %}}
69+
{{% /tab %}}
6970

7071
{{% tab header="Python" %}}
72+
7173
- [pytest](https://pytest.org/) -Uma escolha preferida por muitos, graças à sua simplicidade e aos seus poderosos plugins.
7274
- [unittest](https://docs.python.org/3/library/unittest.html) - A estrutura de testes da biblioteca padrão do Python.
73-
{{% /tab %}}
75+
{{% /tab %}}
7476

7577
{{% tab header="CSharp" %}}
78+
7679
- [NUnit](https://nunit.org/) - Um popular framework de teste unitário para .NET.
7780
- [MS Test](https://docs.microsoft.com/en-us/visualstudio/test/getting-started-with-unit-testing?view=vs-2019) - O Framework de testes unitários da Microsoft.
78-
{{% /tab %}}
81+
{{% /tab %}}
7982

8083
{{% tab header="Ruby" %}}
84+
8185
- [RSpec](https://rspec.info/) - A biblioteca de testes mais utilizada para executar testes Selenium em Ruby.
8286
- [Minitest](https://github.com/seattlerb/minitest) - Um framework de testes leve que vem com a biblioteca padrão do Ruby.
83-
{{% /tab %}}
87+
{{% /tab %}}
8488

8589
{{% tab header="JavaScript" %}}
90+
8691
- [Jest](https://jestjs.io/) - Principalmente conhecido como um framework de teste para React, também pode ser utilizado para testes Selenium.
8792
- [Mocha](https://mochajs.org/) - A biblioteca JS mais comum para executar testes Selenium.
88-
{{% /tab %}}
93+
{{% /tab %}}
8994

9095
{{% tab header="Kotlin" %}}
9196

9297
{{% /tab %}}
9398
{{< /tabpane >}}
9499

95-
96100
### Instalando
97101

98102
Isto é muito semelhante ao que foi requerido em [Install a Selenium Library]({{< ref "install_library.md" >}}).
@@ -132,7 +136,7 @@ In your project's `package.json`, adicionar requisito às `dependências`:
132136

133137
{{< tabpane text=true >}}
134138
{{< tab header="Java" >}}
135-
{{< badge-code >}}
139+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L30-L31" >}}
136140
{{< /tab >}}
137141
{{% tab header="Python" %}}
138142
{{< badge-code >}}
@@ -154,20 +158,31 @@ In your project's `package.json`, adicionar requisito às `dependências`:
154158
### Configuarar e Desconfigurar
155159

156160
{{< tabpane text=true >}}
157-
{{< tab header="Java" >}}
158-
{{< badge-code >}}
159-
{{< /tab >}}
161+
{{% tab header="Java" %}}
162+
163+
### Set Up
164+
165+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L19-L22" >}}
166+
167+
### Tear Down
168+
169+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java#L45-L48" >}}
170+
171+
{{% /tab %}}
160172
{{% tab header="Python" %}}
161173
{{< badge-code >}}
162174
{{% /tab %}}
163175
{{< tab header="CSharp" >}}
164176
{{< badge-code >}}
165177
{{< /tab >}}
166178
{{% tab header="Ruby" %}}
179+
167180
### Set Up
181+
168182
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb#L7-L9" >}}
169183

170184
### Tear Down
185+
171186
{{< gh-codeblock path="examples/ruby/spec/spec_helper.rb#L28" >}}
172187
{{% /tab %}}
173188
{{< tab header="JavaScript" >}}
@@ -182,6 +197,7 @@ In your project's `package.json`, adicionar requisito às `dependências`:
182197

183198
{{< tabpane text=true >}}
184199
{{% tab header="Java" %}}
200+
185201
### Maven
186202

187203
```shell
@@ -205,9 +221,11 @@ gradle clean test
205221
{{< gh-codeblock path="examples/ruby/README.md#L26" >}}
206222
{{% /tab %}}
207223
{{% tab header="JavaScript" %}}
224+
208225
```shell
209226
mocha runningTests.spec.js
210227
```
228+
211229
{{% /tab %}}
212230
{{< tab header="Kotlin" >}}
213231
{{< badge-code >}}

0 commit comments

Comments
 (0)