From 9ddfec6b649660749e318982c20aa288a2d7378c Mon Sep 17 00:00:00 2001 From: Simon Benzer Date: Sun, 18 Aug 2024 17:11:38 -0400 Subject: [PATCH 1/2] added setup and teardown python examples to Organizing and Executing Selenium Code --- .../python/tests/getting_started/using_selenium_tests.py | 8 ++++++++ .../webdriver/getting_started/using_selenium.en.md | 9 +++++++++ .../webdriver/getting_started/using_selenium.ja.md | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/examples/python/tests/getting_started/using_selenium_tests.py b/examples/python/tests/getting_started/using_selenium_tests.py index 8af0a1deeb20..b2f8f830050d 100644 --- a/examples/python/tests/getting_started/using_selenium_tests.py +++ b/examples/python/tests/getting_started/using_selenium_tests.py @@ -23,3 +23,11 @@ def test_eight_components(): assert value == "Received!" driver.quit() + +def setup(): + driver = webdriver.Chrome() + driver.get("https://www.selenium.dev/selenium/web/web-form.html") + return driver + +def teardown(driver): + driver.quit() diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md index a816140525fe..156767a165d8 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.en.md @@ -174,6 +174,15 @@ In your project's `package.json`, add requirement to `dependencies`: {{% /tab %}} {{% tab header="Python" %}} + +### Set Up + +{{< gh-codeblock path="examples/python/tests/getting_started/using_selenium_tests.py#L27-L30" >}} + +### Tear Down + +{{< gh-codeblock path="examples/python/tests/getting_started/using_selenium_tests.py#L32-33" >}} + {{< badge-code >}} {{% /tab %}} {{< tab header="CSharp" >}} diff --git a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md index 01426ac0425e..e2712e7d250b 100644 --- a/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md +++ b/website_and_docs/content/documentation/webdriver/getting_started/using_selenium.ja.md @@ -170,6 +170,15 @@ In your project's `package.json`, add requirement to `dependencies`: {{% /tab %}} {{% tab header="Python" %}} + +### Set Up + +{{< gh-codeblock path="examples/python/tests/getting_started/using_selenium_tests.py#L27-L30" >}} + +### Tear Down + +{{< gh-codeblock path="examples/python/tests/getting_started/using_selenium_tests.py#L32-33" >}} + {{< badge-code >}} {{% /tab %}} {{< tab header="CSharp" >}} From bbded4685f577cece61bd2020fa0749537d19692 Mon Sep 17 00:00:00 2001 From: Simon Benzer Date: Sun, 18 Aug 2024 17:44:12 -0400 Subject: [PATCH 2/2] added examples for selenium manager to documentation --- .../python/tests/selenium_manager/usage.py | 12 ++++++++++ .../documentation/selenium_manager.en.md | 23 +++++++++++++++++++ .../documentation/selenium_manager.ja.md | 23 +++++++++++++++++++ .../documentation/selenium_manager.pt-br.md | 23 +++++++++++++++++++ .../documentation/selenium_manager.zh-cn.md | 23 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 examples/python/tests/selenium_manager/usage.py diff --git a/examples/python/tests/selenium_manager/usage.py b/examples/python/tests/selenium_manager/usage.py new file mode 100644 index 000000000000..c9e93ca542b0 --- /dev/null +++ b/examples/python/tests/selenium_manager/usage.py @@ -0,0 +1,12 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.chrome.service import Service + +def setup_without_selenium_manager(): + chrome_service = Service(executable_path='path/to/chrome.exe') + driver = webdriver.Chrome(chrome_service) + return driver + +def setup_with_selenium_manager(): + driver = webdriver.Chrome() + return driver \ No newline at end of file diff --git a/website_and_docs/content/documentation/selenium_manager.en.md b/website_and_docs/content/documentation/selenium_manager.en.md index 1fabb70e67ec..157fd982d751 100644 --- a/website_and_docs/content/documentation/selenium_manager.en.md +++ b/website_and_docs/content/documentation/selenium_manager.en.md @@ -209,6 +209,29 @@ INFO Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\117.0.5938 INFO Browser path: C:\Users\boni\.cache\selenium\chrome\win64\117.0.5938.22\chrome.exe ``` +### Implementing Selenium Manager in Your Scripts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< /tab >}} +{{% tab header="Python" %}} +**Previously** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L5-L8" >}} +**Selenium Manager** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L10-L12" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + ## Selenium Grid Selenium Manager allows you to configure the drivers automatically when setting up Selenium Grid. To that aim, you need to include the argument `--selenium-manager true` in the command to start Selenium Grid. For more details, visit the [Selenium Grid starting page](https://www.selenium.dev/documentation/grid/getting_started/). diff --git a/website_and_docs/content/documentation/selenium_manager.ja.md b/website_and_docs/content/documentation/selenium_manager.ja.md index 1fabb70e67ec..157fd982d751 100644 --- a/website_and_docs/content/documentation/selenium_manager.ja.md +++ b/website_and_docs/content/documentation/selenium_manager.ja.md @@ -209,6 +209,29 @@ INFO Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\117.0.5938 INFO Browser path: C:\Users\boni\.cache\selenium\chrome\win64\117.0.5938.22\chrome.exe ``` +### Implementing Selenium Manager in Your Scripts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< /tab >}} +{{% tab header="Python" %}} +**Previously** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L5-L8" >}} +**Selenium Manager** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L10-L12" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + ## Selenium Grid Selenium Manager allows you to configure the drivers automatically when setting up Selenium Grid. To that aim, you need to include the argument `--selenium-manager true` in the command to start Selenium Grid. For more details, visit the [Selenium Grid starting page](https://www.selenium.dev/documentation/grid/getting_started/). diff --git a/website_and_docs/content/documentation/selenium_manager.pt-br.md b/website_and_docs/content/documentation/selenium_manager.pt-br.md index 1fabb70e67ec..157fd982d751 100644 --- a/website_and_docs/content/documentation/selenium_manager.pt-br.md +++ b/website_and_docs/content/documentation/selenium_manager.pt-br.md @@ -209,6 +209,29 @@ INFO Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\117.0.5938 INFO Browser path: C:\Users\boni\.cache\selenium\chrome\win64\117.0.5938.22\chrome.exe ``` +### Implementing Selenium Manager in Your Scripts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< /tab >}} +{{% tab header="Python" %}} +**Previously** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L5-L8" >}} +**Selenium Manager** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L10-L12" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + ## Selenium Grid Selenium Manager allows you to configure the drivers automatically when setting up Selenium Grid. To that aim, you need to include the argument `--selenium-manager true` in the command to start Selenium Grid. For more details, visit the [Selenium Grid starting page](https://www.selenium.dev/documentation/grid/getting_started/). diff --git a/website_and_docs/content/documentation/selenium_manager.zh-cn.md b/website_and_docs/content/documentation/selenium_manager.zh-cn.md index 1fabb70e67ec..157fd982d751 100644 --- a/website_and_docs/content/documentation/selenium_manager.zh-cn.md +++ b/website_and_docs/content/documentation/selenium_manager.zh-cn.md @@ -209,6 +209,29 @@ INFO Driver path: C:\Users\boni\.cache\selenium\chromedriver\win64\117.0.5938 INFO Browser path: C:\Users\boni\.cache\selenium\chrome\win64\117.0.5938.22\chrome.exe ``` +### Implementing Selenium Manager in Your Scripts + +{{< tabpane text=true >}} +{{< tab header="Java" >}} +{{< /tab >}} +{{% tab header="Python" %}} +**Previously** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L5-L8" >}} +**Selenium Manager** +{{< gh-codeblock path="examples/python/tests/selenium_manager/usage.py#L10-L12" >}} +{{< badge-code >}} +{{< /tab >}} +{{< tab header="CSharp" >}} +{{< /tab >}} +{{< tab header="Ruby" >}} +{{< /tab >}} +{{< tab header="JavaScript" >}} +{{< /tab >}} +{{< tab header="Kotlin" >}} +{{< badge-code >}} +{{< /tab >}} +{{< /tabpane >}} + ## Selenium Grid Selenium Manager allows you to configure the drivers automatically when setting up Selenium Grid. To that aim, you need to include the argument `--selenium-manager true` in the command to start Selenium Grid. For more details, visit the [Selenium Grid starting page](https://www.selenium.dev/documentation/grid/getting_started/).