Skip to content

Commit e4d80d3

Browse files
committed
rename page and add section on Usage
1 parent 7be8bee commit e4d80d3

File tree

14 files changed

+239
-100
lines changed

14 files changed

+239
-100
lines changed

Diff for: examples/dotnet/SeleniumDocs/GettingStarted/RunningTestsTest.cs renamed to examples/dotnet/SeleniumDocs/GettingStarted/UsingSeleniumTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
namespace SeleniumDocs.GettingStarted
77
{
88
[TestClass]
9-
public class RunningTestsTest
9+
public class UsingSeleniumTest
1010
{
1111

1212
[TestMethod]
13-
public void ChromeSession()
13+
public void EightComponents()
1414
{
1515
IWebDriver driver = new ChromeDriver();
1616

Diff for: examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
import org.junit.jupiter.api.Assertions;
66
import org.junit.jupiter.api.Test;
77
import org.openqa.selenium.By;
8+
import org.openqa.selenium.Pdf;
89
import org.openqa.selenium.WebElement;
910
import org.openqa.selenium.chrome.ChromeDriver;
1011
import org.openqa.selenium.chrome.ChromeDriverService;
1112
import org.openqa.selenium.chrome.ChromeOptions;
1213
import org.openqa.selenium.chromium.ChromiumDriverLogLevel;
14+
import org.openqa.selenium.print.PrintOptions;
1315

14-
import java.io.File;
15-
import java.io.IOException;
16-
import java.io.PrintStream;
16+
import java.io.*;
1717
import java.nio.file.Files;
1818
import java.nio.file.Path;
1919
import java.nio.file.Paths;
20+
import java.util.Base64;
2021
import java.util.regex.Pattern;
2122

2223
public class ChromeTest {
@@ -35,9 +36,14 @@ public void quit() {
3536
}
3637

3738
@Test
38-
public void basicOptions() {
39+
public void basicOptions() throws IOException {
3940
ChromeOptions options = new ChromeOptions();
4041
driver = new ChromeDriver(options);
42+
driver.get("https://www.selenium.dev");
43+
44+
String content = driver.print(new PrintOptions()).getContent();
45+
byte[] bytes = Base64.getDecoder().decode(content);
46+
Files.write(Paths.get("printed.pdf"), bytes);
4147
}
4248

4349
@Test

Diff for: examples/java/src/test/java/dev/selenium/getting_started/RunningTestsTest.java renamed to examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import static org.junit.jupiter.api.Assertions.assertEquals;
1212

13-
public class RunningTestsTest {
13+
public class UsingSelenium {
1414

1515
@Test
1616
public void eightComponents() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package dev.selenium.interactions;
2+
3+
import dev.selenium.BaseChromeTest;
4+
import org.junit.jupiter.api.Assertions;
5+
import org.junit.jupiter.api.Test;
6+
import org.openqa.selenium.By;
7+
import org.openqa.selenium.NoSuchElementException;
8+
import org.openqa.selenium.print.PrintOptions;
9+
import org.openqa.selenium.remote.RemoteWebDriver;
10+
11+
import java.io.IOException;
12+
import java.nio.file.Files;
13+
import java.nio.file.Paths;
14+
import java.util.Base64;
15+
16+
public class SavingTest extends BaseChromeTest {
17+
@Test
18+
public void prints() throws IOException {
19+
driver.get("https://www.selenium.dev");
20+
21+
String content = ((RemoteWebDriver) driver).print(new PrintOptions()).getContent();
22+
byte[] bytes = Base64.getDecoder().decode(content);
23+
Files.write(Paths.get("selenium.pdf"), bytes);
24+
}
25+
}

Diff for: examples/ruby/spec/getting_started/running_tests_spec.rb renamed to examples/ruby/spec/getting_started/using_selenium_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe 'Running Tests' do
5+
RSpec.describe 'Using Selenium' do
66
it 'uses eight components' do
77
driver = Selenium::WebDriver.for :chrome
88

Diff for: website_and_docs/content/documentation/webdriver/getting_started/first_script.en.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,15 @@ See [Quitting Sessions]({{< ref "../drivers/#quitting-sessions" >}}).
226226
{{< /tab >}}
227227
{{< /tabpane >}}
228228

229+
## Running Selenium File
230+
231+
{{< alert-code >}}
232+
Add example for how to execute each of the above pages via command line
233+
{{< /alert-code >}}
234+
235+
229236
## Next Steps
230237

231238
Most Selenium users execute many sessions and need to organize them to minimize duplication and keep the code
232-
more maintainable.
233-
To see these 8 components in a single script as part of a test runner,
234-
read on to learn about [Organizing and Executing Selenium in Tests]({{< ref "running_tests.md" >}}).
239+
more maintainable. Read on to learn about how to put this code into context for your use case with
240+
[Using Selenium]({{< ref "using_selenium.md" >}}).

Diff for: website_and_docs/content/documentation/webdriver/getting_started/first_script.ja.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,15 @@ See [Quitting Sessions]({{< ref "../drivers/#quitting-sessions" >}}).
229229
{{< /tabpane >}}
230230

231231

232+
## Running Selenium File
233+
234+
{{< alert-code >}}
235+
Add example for how to execute each of the above pages via command line
236+
{{< /alert-code >}}
237+
238+
232239
## Next Steps
233240

234241
Most Selenium users execute many sessions and need to organize them to minimize duplication and keep the code
235-
more maintainable.
236-
To see these 8 components in a single script as part of a test runner,
237-
read on to learn about [Organizing and Executing Selenium in Tests]({{< ref "running_tests.md" >}}).
242+
more maintainable. Read on to learn about how to put this code into context for your use case with
243+
[Using Selenium]({{< ref "using_selenium.md" >}}).

Diff for: website_and_docs/content/documentation/webdriver/getting_started/first_script.pt-br.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,15 @@ See [Quitting Sessions]({{< ref "../drivers/#quitting-sessions" >}}).
228228
{{< /tabpane >}}
229229

230230

231+
## Running Selenium File
232+
233+
{{< alert-code >}}
234+
Add example for how to execute each of the above pages via command line
235+
{{< /alert-code >}}
236+
237+
231238
## Próximos Passos
232239

233240
Most Selenium users execute many sessions and need to organize them to minimize duplication and keep the code
234-
more maintainable.
235-
To see these 8 components in a single script as part of a test runner,
236-
read on to learn about [Organizing and Executing Selenium in Tests]({{< ref "running_tests.md" >}}).
241+
more maintainable. Read on to learn about how to put this code into context for your use case with
242+
[Using Selenium]({{< ref "using_selenium.md" >}}).

Diff for: website_and_docs/content/documentation/webdriver/getting_started/first_script.zh-cn.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,15 @@ See [Quitting Sessions]({{< ref "../drivers/#quitting-sessions" >}}).
241241
{{< /tabpane >}}
242242

243243

244+
## Running Selenium File
245+
246+
{{< alert-code >}}
247+
Add example for how to execute each of the above pages via command line
248+
{{< /alert-code >}}
249+
250+
244251
## 接下来的步骤
245252

246253
Most Selenium users execute many sessions and need to organize them to minimize duplication and keep the code
247-
more maintainable.
248-
To see these 8 components in a single script as part of a test runner,
249-
read on to learn about [Organizing and Executing Selenium in Tests]({{< ref "running_tests.md" >}}).
254+
more maintainable. Read on to learn about how to put this code into context for your use case with
255+
[Using Selenium]({{< ref "using_selenium.md" >}}).

Diff for: website_and_docs/content/documentation/webdriver/getting_started/running_tests.en.md renamed to website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md

+44-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,52 @@
11
---
2-
title: "Organizing and Executing Selenium in Tests"
3-
linkTitle: "Running Tests"
2+
title: "Organizing and Executing Selenium Code"
3+
linkTitle: "Using Selenium"
44
weight: 10
55
description: >
6-
Scaling Selenium execution with a Test Runner Framework
6+
Scaling Selenium execution with an IDE and a Test Runner library
77
---
88

9+
{{< alert-content >}}
10+
This page is very incomplete and has placeholders for things that need to be added or expounded on.
11+
{{< /alert-content >}}
12+
913
If you want to run more than a handful of one-off scripts, you need to
10-
be able to organize and work with your code.
11-
Most people use Selenium for testing, so that is the context that often
12-
gets used to talk about executing Selenium code, so it is worth giving
13-
an overview of how to use Selenium in this context.
14-
Running Selenium in tests requires making assertions and using common setup and teardown code.
15-
It often involves running multiple sessions in parallel,
16-
and sometimes running specific subsets of sessions.
14+
be able to organize and work with your code. This page should give you
15+
ideas for how to actually do productive things with your Selenium code.
16+
17+
## Common Uses
18+
19+
Most people use Selenium to execute automated tests for web applications,
20+
but Selenium support any use case of browser automation.
21+
22+
### Repetitive Tasks
23+
24+
### Testing
25+
26+
Running Selenium for testing requires making assertions on actions taken by Selenium.
27+
So a good assertion library is required. Additional features to provide structure for tests
28+
require use of [Test Runner](#test-runners)
1729

1830

1931
## IDEs
2032

21-
First and foremost, you won't be very effective in building out a test suite without a good
33+
Regardless of how you use Selenium code,
34+
you won't be very effective writing or executing it without a good
2235
Integrated Developer Environment. Here are some common options...
2336

37+
* Eclipse
38+
* IntelliJ
39+
* PyCharm
40+
* RubyMine
41+
* Rider
42+
* WebStorm
43+
* VS Code
2444

25-
## Test Runners
45+
## Test Runner
46+
47+
Even if you aren't using Selenium for testing, if you have advanced use cases, it might make
48+
sense to use a test runner to better organize your code. Being able to use before/after hooks
49+
and run things in groups or in parallel can be very useful.
2650

2751
### Choosing
2852
There are many different test runners available.
@@ -145,7 +169,7 @@ Use the Java bindings for Kotlin.
145169
### Executing
146170

147171
{{< tabpane text=true langEqualsHeader=true >}}
148-
{{< tab header="Java" >}}
172+
{{% tab header="Java" %}}
149173
### Maven
150174

151175
```shell
@@ -158,7 +182,7 @@ mvn clean test
158182
gradle clean test
159183
```
160184

161-
{{< /tab >}}
185+
{{% /tab %}}
162186
{{% tab header="Python" %}}
163187
{{< badge-code >}}
164188
{{% /tab %}}
@@ -168,11 +192,11 @@ gradle clean test
168192
{{< tab header="Ruby" >}}
169193
{{< badge-code >}}
170194
{{< /tab >}}
171-
{{< tab header="JavaScript" >}}
195+
{{% tab header="JavaScript" %}}
172196
```shell
173197
mocha runningTests.spec.js
174198
```
175-
{{< /tab >}}
199+
{{% /tab %}}
176200
{{< tab header="Kotlin" >}}
177201
{{< badge-code >}}
178202
{{< /tab >}}
@@ -185,16 +209,16 @@ Here's an example of that code using a test runner:
185209

186210
{{< tabpane text=true langEqualsHeader=true >}}
187211
{{< tab header="Java" >}}
188-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/RunningTestsTest.java" >}}
212+
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/getting_started/UsingSeleniumTest.java" >}}
189213
{{< /tab >}}
190214
{{< tab header="Python" >}}
191-
{{< gh-codeblock path="examples/python/tests/getting_started/test_running_tests.py" >}}
215+
{{< gh-codeblock path="examples/python/tests/getting_started/using_selenium_tests.py" >}}
192216
{{< /tab >}}
193217
{{< tab header="CSharp" >}}
194-
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/GettingStarted/RunningTestsTest.cs" >}}
218+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/GettingStarted/UsingSeleniumTest.cs" >}}
195219
{{< /tab >}}
196220
{{< tab header="Ruby" >}}
197-
{{< gh-codeblock path="examples/ruby/spec/getting_started/running_tests_spec.rb" >}}
221+
{{< gh-codeblock path="examples/ruby/spec/getting_started/using_selenium_spec.rb" >}}
198222
{{< /tab >}}
199223
{{< tab header="JavaScript" >}}
200224
{{< badge-code >}}

0 commit comments

Comments
 (0)