Skip to content

Updated Python Examples for Options #2010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 30 additions & 24 deletions examples/python/tests/drivers/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,101 @@

def test_page_load_strategy_normal():
options = webdriver.ChromeOptions()

options.page_load_strategy = 'normal'
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()


def test_page_load_strategy_eager():
options = webdriver.ChromeOptions()

options.page_load_strategy = 'eager'
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()


def test_page_load_strategy_none():
options = webdriver.ChromeOptions()

options.page_load_strategy = 'none'
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_capabilities():
options = webdriver.ChromeOptions()
options.browser_version = 'stable'
options.platform_name = 'any'
options.accept_insecure_certs = True
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_timeouts_script():
options = webdriver.ChromeOptions()
options.timeouts = { 'script': 5000 }
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_timeouts_page_load():
options = webdriver.ChromeOptions()
options.timeouts = { 'pageLoad': 5000 }
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_timeouts_implicit_wait():
options = webdriver.ChromeOptions()
options.timeouts = { 'implicit': 5000 }
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_unhandled_prompt():
options = webdriver.ChromeOptions()
options.unhandled_prompt_behavior = 'accept'
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_set_window_rect():
options = webdriver.FirefoxOptions()
options.set_window_rect = True # Full support in Firefox
driver = webdriver.Firefox(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_strict_file_interactability():
options = webdriver.ChromeOptions()
options.strict_file_interactability = True
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()

def test_proxy():
options = webdriver.ChromeOptions()
options.proxy = Proxy({ 'proxyType': ProxyType.MANUAL, 'httpProxy' : 'http.proxy:1234'})
driver = webdriver.Chrome(options=options)

driver.get("https://www.selenium.dev/")
driver.quit()
driver.quit()

def test_set_browser_name():
options = webdriver.ChromeOptions()
assert options.capabilities['browserName'] == 'chrome'
driver = webdriver.Chrome(options=options)
driver.get("https://www.selenium.dev/")
driver.quit()

def test_set_browser_version():
options = webdriver.ChromeOptions()
options.browser_version = 'latest'
assert options.capabilities['browserVersion'] == 'latest'
driver = webdriver.Chrome(options=options)
driver.get("https://www.selenium.dev/")
driver.quit()

def test_platform_name():
options = webdriver.ChromeOptions()
options.platform_name = 'any'
driver = webdriver.Chrome(options=options)
driver.get("https://www.selenium.dev/")
driver.quit()

def test_accept_insecure_certs():
options = webdriver.ChromeOptions()
options.accept_insecure_certs = True
driver = webdriver.Chrome(options=options)
driver.get("https://www.selenium.dev/")
driver.quit()
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Browser name is set by default when using an Options class instance.
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L73-74" >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L36" >}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L79-80" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand All @@ -61,7 +61,7 @@ it will be automatically downloaded by [Selenium Manager]({{< ref "../../seleniu
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L80-82" >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L37" >}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L86-88" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -117,7 +117,7 @@ event fire is returned.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L21-L23">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L9-L10">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L7-9">}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down Expand Up @@ -174,7 +174,7 @@ event fire is returned.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L34-L36">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L19-L20">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L15-L17">}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down Expand Up @@ -230,7 +230,7 @@ WebDriver only waits until the initial page is downloaded.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L47-L49">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L29-L30">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L23-L25">}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down Expand Up @@ -290,7 +290,7 @@ setting `platformName` sets the OS at the remote-end.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L88-L90">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L38">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L94-96">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -328,7 +328,7 @@ effect for the entire session.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L60-L61">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L39-40">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L101-103">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -363,7 +363,7 @@ is imposed when a new session is created by WebDriver.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L96-L98">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L47-48">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L30-32">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -392,7 +392,7 @@ _TimeoutException_.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L111-L113">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L55-56">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L37-39">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand All @@ -419,7 +419,7 @@ is imposed when a new session is created by WebDriver.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L126-L128">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L63-64">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L44-46">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -457,7 +457,7 @@ user prompt encounters at the remote-end. This is defined by
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L141-L142">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L71-72">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L51-53">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand All @@ -482,7 +482,7 @@ Indicates whether the remote end supports all of the [resizing and repositioning
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L151-L152">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L79-80">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L58-60">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -510,7 +510,7 @@ when using _Element Send Keys_ with hidden file upload controls.
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L163-L164">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L87-88">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L65-67">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -571,7 +571,7 @@ public class ProxyTest {
```
{{% /tab %}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L95-96">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L72-74">}}
{{% /tab %}}
{{% tab header="CSharp" %}}
```CSharp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Browser name is set by default when using an Options class instance.
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L73-74" >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L36" >}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L79-80" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -62,7 +62,7 @@ it will be automatically downloaded by [Selenium Manager]({{< ref "../../seleniu
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L80-82" >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L37" >}}
{{< gh-codeblock path="examples/python/tests/drivers/test_options.py#L86-88" >}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -115,7 +115,7 @@ WebDriver は [load](https://developer.mozilla.org/ja/docs/Web/API/Window/load_e
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L21-L23">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L9-L10">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L7-9">}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down Expand Up @@ -171,7 +171,7 @@ WebDriver は、[DOMContentLoaded](https://developer.mozilla.org/ja/docs/Web/API
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L34-L36">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L19-L20">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L15-L17">}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down Expand Up @@ -226,7 +226,7 @@ WebDriver は、最初のページがダウンロードされるまで待機し
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L47-L49">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L29-L30">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L23-L25">}}
{{< /tab >}}
{{< tab header="CSharp" >}}
using OpenQA.Selenium;
Expand Down Expand Up @@ -284,7 +284,7 @@ fun main() {
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L88-L90">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L38">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L94-96">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -316,7 +316,7 @@ fun main() {
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L60-L61">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L39-40">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L101-103">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -348,7 +348,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L96-L98">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L47-48">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L30-32">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand All @@ -374,7 +374,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L111-L113">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L55-56">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L37-39">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand All @@ -399,7 +399,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L126-L128">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L63-64">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L44-46">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -436,7 +436,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L141-L142">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L71-72">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L51-53">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand All @@ -462,7 +462,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L151-L152">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L79-80">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L58-60">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand All @@ -489,7 +489,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/drivers/OptionsTest.java#L163-L164">}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L87-88">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L65-67">}}
{{% /tab %}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -545,7 +545,7 @@ public class ProxyTest {
```
{{% /tab %}}
{{% tab header="Python" %}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L95-96">}}
{{< gh-codeblock path="/examples/python/tests/drivers/test_options.py#L72-74">}}
{{% /tab %}}
{{% tab header="CSharp" %}}
```CSharp
Expand Down
Loading
Loading