Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bf2711a

Browse files
pmartinez1harsha509
andauthored
Update python drivers (options) docs with code examples (#1845)[deploy site]
* Update Ruby code-block to show .quit * Update python examples for Drivers - options docs Added/moved examples for python under the Drivers section * replace existing example url in python tests with selenium.dev --------- Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com>
1 parent e0439d1 commit bf2711a

File tree

9 files changed

+139
-127
lines changed

9 files changed

+139
-127
lines changed

‎examples/python/tests/drivers/test_options.py‎

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from selenium import webdriver
2+
from selenium.webdriver.common.proxy import Proxy
3+
from selenium.webdriver.common.proxy import ProxyType
24

35

46
def test_page_load_strategy_normal():
@@ -7,7 +9,7 @@ def test_page_load_strategy_normal():
79
options.page_load_strategy = 'normal'
810
driver = webdriver.Chrome(options=options)
911

10-
driver.get("http://www.google.com")
12+
driver.get("https://www.selenium.dev/")
1113
driver.quit()
1214

1315

@@ -17,7 +19,7 @@ def test_page_load_strategy_eager():
1719
options.page_load_strategy = 'eager'
1820
driver = webdriver.Chrome(options=options)
1921

20-
driver.get("http://www.google.com")
22+
driver.get("https://www.selenium.dev/")
2123
driver.quit()
2224

2325

@@ -27,5 +29,71 @@ def test_page_load_strategy_none():
2729
options.page_load_strategy = 'none'
2830
driver = webdriver.Chrome(options=options)
2931

30-
driver.get("http://www.google.com")
32+
driver.get("https://www.selenium.dev/")
3133
driver.quit()
34+
35+
def test_capabilities():
36+
options = webdriver.ChromeOptions()
37+
options.browser_version = 'stable'
38+
options.platform_name = 'any'
39+
options.accept_insecure_certs = True
40+
driver = webdriver.Chrome(options=options)
41+
42+
driver.get("https://www.selenium.dev/")
43+
driver.quit()
44+
45+
def test_timeouts_script():
46+
options = webdriver.ChromeOptions()
47+
options.timeouts = { 'script': 5000 }
48+
driver = webdriver.Chrome(options=options)
49+
50+
driver.get("https://www.selenium.dev/")
51+
driver.quit()
52+
53+
def test_timeouts_page_load():
54+
options = webdriver.ChromeOptions()
55+
options.timeouts = { 'pageLoad': 5000 }
56+
driver = webdriver.Chrome(options=options)
57+
58+
driver.get("https://www.selenium.dev/")
59+
driver.quit()
60+
61+
def test_timeouts_implicit_wait():
62+
options = webdriver.ChromeOptions()
63+
options.timeouts = { 'implicit': 5000 }
64+
driver = webdriver.Chrome(options=options)
65+
66+
driver.get("https://www.selenium.dev/")
67+
driver.quit()
68+
69+
def test_unhandled_prompt():
70+
options = webdriver.ChromeOptions()
71+
options.unhandled_prompt_behavior = 'accept'
72+
driver = webdriver.Chrome(options=options)
73+
74+
driver.get("https://www.selenium.dev/")
75+
driver.quit()
76+
77+
def test_set_window_rect():
78+
options = webdriver.FirefoxOptions()
79+
options.set_window_rect = True # Full support in Firefox
80+
driver = webdriver.Firefox(options=options)
81+
82+
driver.get("https://www.selenium.dev/")
83+
driver.quit()
84+
85+
def test_strict_file_interactability():
86+
options = webdriver.ChromeOptions()
87+
options.strict_file_interactability = True
88+
driver = webdriver.Chrome(options=options)
89+
90+
driver.get("https://www.selenium.dev/")
91+
driver.quit()
92+
93+
def test_proxy():
94+
options = webdriver.ChromeOptions()
95+
options.proxy = Proxy({ 'proxyType': ProxyType.MANUAL, 'httpProxy' : 'http.proxy:1234'})
96+
driver = webdriver.Chrome(options=options)
97+
98+
driver.get("https://www.selenium.dev/")
99+
driver.quit()

‎website_and_docs/content/documentation/webdriver/drivers/_index.en.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ on the local machine.
3030
{{< badge-code >}}
3131
{{< /tab >}}
3232
{{% tab header="Python" %}}
33-
{{< badge-code >}}
33+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L10" >}}
3434
{{% /tab %}}
3535
{{< tab header="CSharp" >}}
3636
{{< badge-code >}}
@@ -64,13 +64,13 @@ and it is recommended to always use `quit` to end the session
6464
{{< badge-code >}}
6565
{{< /tab >}}
6666
{{% tab header="Python" %}}
67-
{{< badge-code >}}
67+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L13" >}}
6868
{{% /tab %}}
6969
{{< tab header="CSharp" >}}
7070
{{< badge-code >}}
7171
{{< /tab >}}
7272
{{< tab header="Ruby" >}}
73-
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L15" >}}
73+
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L16" >}}
7474
{{< /tab >}}
7575
{{< tab header="JavaScript" >}}
7676
{{< badge-code >}}

‎website_and_docs/content/documentation/webdriver/drivers/_index.ja.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ weight: 3
3030
{{< badge-code >}}
3131
{{< /tab >}}
3232
{{% tab header="Python" %}}
33-
{{< badge-code >}}
33+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L10" >}}
3434
{{% /tab %}}
3535
{{< tab header="CSharp" >}}
3636
{{< badge-code >}}
@@ -63,13 +63,13 @@ weight: 3
6363
{{< badge-code >}}
6464
{{< /tab >}}
6565
{{% tab header="Python" %}}
66-
{{< badge-code >}}
66+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L13" >}}
6767
{{% /tab %}}
6868
{{< tab header="CSharp" >}}
6969
{{< badge-code >}}
7070
{{< /tab >}}
7171
{{< tab header="Ruby" >}}
72-
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L15" >}}
72+
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L16" >}}
7373
{{< /tab >}}
7474
{{< tab header="JavaScript" >}}
7575
{{< badge-code >}}

‎website_and_docs/content/documentation/webdriver/drivers/_index.pt-br.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ on the local machine.
3030
{{< badge-code >}}
3131
{{< /tab >}}
3232
{{% tab header="Python" %}}
33-
{{< badge-code >}}
33+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L10" >}}
3434
{{% /tab %}}
3535
{{< tab header="CSharp" >}}
3636
{{< badge-code >}}
@@ -64,13 +64,13 @@ and it is recommended to always use `quit` to end the session
6464
{{< badge-code >}}
6565
{{< /tab >}}
6666
{{% tab header="Python" %}}
67-
{{< badge-code >}}
67+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L13" >}}
6868
{{% /tab %}}
6969
{{< tab header="CSharp" >}}
7070
{{< badge-code >}}
7171
{{< /tab >}}
7272
{{< tab header="Ruby" >}}
73-
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L15" >}}
73+
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L16" >}}
7474
{{< /tab >}}
7575
{{< tab header="JavaScript" >}}
7676
{{< badge-code >}}

‎website_and_docs/content/documentation/webdriver/drivers/_index.zh-cn.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ weight: 3
3030
{{< badge-code >}}
3131
{{< /tab >}}
3232
{{% tab header="Python" %}}
33-
{{< badge-code >}}
33+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L10" >}}
3434
{{% /tab %}}
3535
{{< tab header="CSharp" >}}
3636
{{< badge-code >}}
@@ -64,13 +64,13 @@ weight: 3
6464
{{< badge-code >}}
6565
{{< /tab >}}
6666
{{% tab header="Python" %}}
67-
{{< badge-code >}}
67+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L13" >}}
6868
{{% /tab %}}
6969
{{< tab header="CSharp" >}}
7070
{{< badge-code >}}
7171
{{< /tab >}}
7272
{{< tab header="Ruby" >}}
73-
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L15" >}}
73+
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L16" >}}
7474
{{< /tab >}}
7575
{{< tab header="JavaScript" >}}
7676
{{< badge-code >}}

‎website_and_docs/content/documentation/webdriver/drivers/options.en.md‎

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Browser name is set by default when using an Options class instance.
3434
{{< badge-code >}}
3535
{{< /tab >}}
3636
{{% tab header="Python" %}}
37-
{{< badge-code >}}
37+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L36" >}}
3838
{{% /tab %}}
3939
{{< tab header="CSharp" >}}
4040
{{< badge-code >}}
@@ -61,7 +61,7 @@ it will be automatically downloaded by [Selenium Manager]({{< ref "../../seleniu
6161
{{< badge-code >}}
6262
{{< /tab >}}
6363
{{% tab header="Python" %}}
64-
{{< badge-code >}}
64+
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L37" >}}
6565
{{% /tab %}}
6666
{{< tab header="CSharp" >}}
6767
{{< badge-code >}}
@@ -117,7 +117,7 @@ event fire is returned.
117117
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L14-L16">}}
118118
{{< /tab >}}
119119
{{< tab header="Python" text=true >}}
120-
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L7-L9">}}
120+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L9-L10">}}
121121
{{< /tab >}}
122122
{{< tab header="CSharp" >}}
123123
using OpenQA.Selenium;
@@ -174,7 +174,7 @@ event fire is returned.
174174
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L27-L29">}}
175175
{{< /tab >}}
176176
{{< tab header="Python" text=true >}}
177-
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L17-L18">}}
177+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L19-L20">}}
178178
{{< /tab >}}
179179
{{< tab header="CSharp" >}}
180180
using OpenQA.Selenium;
@@ -230,7 +230,7 @@ WebDriver only waits until the initial page is downloaded.
230230
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L40-L42">}}
231231
{{< /tab >}}
232232
{{< tab header="Python" text=true >}}
233-
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L27-L28">}}
233+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L29-L30">}}
234234
{{< /tab >}}
235235
{{< tab header="CSharp" >}}
236236
using OpenQA.Selenium;
@@ -290,7 +290,7 @@ setting `platformName` sets the OS at the remote-end.
290290
{{< badge-code >}}
291291
{{< /tab >}}
292292
{{% tab header="Python" %}}
293-
{{< badge-code >}}
293+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L38">}}
294294
{{% /tab %}}
295295
{{< tab header="CSharp" >}}
296296
{{< badge-code >}}
@@ -328,7 +328,7 @@ effect for the entire session.
328328
{{< badge-code >}}
329329
{{< /tab >}}
330330
{{% tab header="Python" %}}
331-
{{< badge-code >}}
331+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L39-40">}}
332332
{{% /tab %}}
333333
{{< tab header="CSharp" >}}
334334
{{< badge-code >}}
@@ -363,7 +363,7 @@ is imposed when a new session is created by WebDriver.
363363
{{< badge-code >}}
364364
{{< /tab >}}
365365
{{% tab header="Python" %}}
366-
{{< badge-code >}}
366+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L47-48">}}
367367
{{% /tab %}}
368368
{{< tab header="CSharp" >}}
369369
{{< badge-code >}}
@@ -392,7 +392,7 @@ _TimeoutException_.
392392
{{< badge-code >}}
393393
{{< /tab >}}
394394
{{% tab header="Python" %}}
395-
{{< badge-code >}}
395+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L55-56">}}
396396
{{% /tab %}}
397397
{{< tab header="CSharp" >}}
398398
{{< badge-code >}}
@@ -419,7 +419,7 @@ is imposed when a new session is created by WebDriver.
419419
{{< badge-code >}}
420420
{{< /tab >}}
421421
{{% tab header="Python" %}}
422-
{{< badge-code >}}
422+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L63-64">}}
423423
{{% /tab %}}
424424
{{< tab header="CSharp" >}}
425425
{{< badge-code >}}
@@ -457,7 +457,7 @@ user prompt encounters at the remote-end. This is defined by
457457
{{< badge-code >}}
458458
{{< /tab >}}
459459
{{% tab header="Python" %}}
460-
{{< badge-code >}}
460+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L71-72">}}
461461
{{% /tab %}}
462462
{{< tab header="CSharp" >}}
463463
{{< badge-code >}}
@@ -482,7 +482,7 @@ Indicates whether the remote end supports all of the [resizing and repositioning
482482
{{< badge-code >}}
483483
{{< /tab >}}
484484
{{% tab header="Python" %}}
485-
{{< badge-code >}}
485+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L79-80">}}
486486
{{% /tab %}}
487487
{{< tab header="CSharp" >}}
488488
{{< badge-code >}}
@@ -510,7 +510,7 @@ when using _Element Send Keys_ with hidden file upload controls.
510510
{{< badge-code >}}
511511
{{< /tab >}}
512512
{{% tab header="Python" %}}
513-
{{< badge-code >}}
513+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L87-88">}}
514514
{{% /tab %}}
515515
{{< tab header="CSharp" >}}
516516
{{< badge-code >}}
@@ -571,21 +571,7 @@ public class ProxyTest {
571571
```
572572
{{% /tab %}}
573573
{{% tab header="Python" %}}
574-
```python
575-
from selenium import webdriver
576-
577-
PROXY = "<HOST:PORT>"
578-
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
579-
"httpProxy": PROXY,
580-
"ftpProxy": PROXY,
581-
"sslProxy": PROXY,
582-
"proxyType": "MANUAL",
583-
584-
}
585-
586-
with webdriver.Firefox() as driver:
587-
driver.get("https://selenium.dev")
588-
```
574+
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L95-96">}}
589575
{{% /tab %}}
590576
{{% tab header="CSharp" %}}
591577
```CSharp

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /