From 9060cb947137a372eb5fbfaecc8e4864cd6dab90 Mon Sep 17 00:00:00 2001 From: Navin Chandra <98466550+navin772@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:38:31 +0530 Subject: [PATCH] [java][py]: move java and python firefox profile code (#2090)[deploy site] move java and python firefox profile code --- .../dev/selenium/browsers/FirefoxTest.java | 12 ++++++++++ .../python/tests/browsers/test_firefox.py | 14 ++++++++++++ .../webdriver/browsers/firefox.en.md | 20 +++++------------ .../webdriver/browsers/firefox.ja.md | 22 ++++++------------- .../webdriver/browsers/firefox.pt-br.md | 20 +++++------------ .../webdriver/browsers/firefox.zh-cn.md | 20 +++++------------ 6 files changed, 51 insertions(+), 57 deletions(-) diff --git a/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java b/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java index 70ea5c18240..28166e12480 100644 --- a/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java +++ b/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java @@ -205,4 +205,16 @@ public void setContext() { driver.quit(); } + + @Test + public void firefoxProfile() { + FirefoxProfile profile = new FirefoxProfile(); + FirefoxOptions options = new FirefoxOptions(); + profile.setPreference("javascript.enabled", "False"); + options.setProfile(profile); + + driver = new FirefoxDriver(options); + + driver.quit(); + } } diff --git a/examples/python/tests/browsers/test_firefox.py b/examples/python/tests/browsers/test_firefox.py index 82ebc47abf3..5780e16106f 100644 --- a/examples/python/tests/browsers/test_firefox.py +++ b/examples/python/tests/browsers/test_firefox.py @@ -151,3 +151,17 @@ def test_set_context(firefox_driver): # Check if the context is back to content assert driver.execute("GET_CONTEXT")["value"] == "content" + + +def test_firefox_profile(): + from selenium.webdriver.firefox.options import Options + from selenium.webdriver.firefox.firefox_profile import FirefoxProfile + + options = Options() + firefox_profile = FirefoxProfile() + firefox_profile.set_preference("javascript.enabled", False) + options.profile = firefox_profile + + driver = webdriver.Firefox(options=options) + + driver.quit() diff --git a/website_and_docs/content/documentation/webdriver/browsers/firefox.en.md b/website_and_docs/content/documentation/webdriver/browsers/firefox.en.md index f2eac7c6b54..6d7f2c150cf 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/firefox.en.md +++ b/website_and_docs/content/documentation/webdriver/browsers/firefox.en.md @@ -102,20 +102,12 @@ There are several ways to work with Firefox profiles. {{< tabpane langEqualsHeader=true >}} {{< badge-examples >}} - {{< tab header="Java" >}} -FirefoxProfile profile = new FirefoxProfile(); -FirefoxOptions options = new FirefoxOptions(); -options.setProfile(profile); -driver = new FirefoxDriver(options); - {{< /tab >}} - {{< tab header="Python" >}} -from selenium.webdriver.firefox.options import Options -from selenium.webdriver.firefox.firefox_profile import FirefoxProfile -options=Options() -firefox_profile = FirefoxProfile() -firefox_profile.set_preference("javascript.enabled", False) -options.profile = firefox_profile - {{< /tab >}} +{{< tab header="Java" >}} +{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L211-L216" >}} +{{< /tab >}} +{{< tab header="Python" >}} +{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L157-L165" >}} +{{< /tab >}} {{< tab header="CSharp" >}} var options = new FirefoxOptions(); var profile = new FirefoxProfile(); diff --git a/website_and_docs/content/documentation/webdriver/browsers/firefox.ja.md b/website_and_docs/content/documentation/webdriver/browsers/firefox.ja.md index 126638d5acb..8b565f4c4ee 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/firefox.ja.md +++ b/website_and_docs/content/documentation/webdriver/browsers/firefox.ja.md @@ -106,21 +106,13 @@ Firefoxプロファイルを操作するにはいくつかの方法がありま