Skip to content

Commit

Permalink
[java][py]: move java and python firefox profile code (#2090)[deploy …
Browse files Browse the repository at this point in the history
…site]

move java and python firefox profile code
  • Loading branch information
navin772 authored Dec 2, 2024
1 parent 3a3c6b9 commit 9060cb9
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 57 deletions.
12 changes: 12 additions & 0 deletions examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
14 changes: 14 additions & 0 deletions examples/python/tests/browsers/test_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,13 @@ Firefoxプロファイルを操作するにはいくつかの方法がありま

<div>
{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" >}}
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile);
driver = new RemoteWebDriver(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="CSharp" >}}
{{< 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();
options.Profile = profile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,12 @@ Existem várias formas de trabalhar com perfis Firefox

<div>
{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" >}}
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile);
driver = new RemoteWebDriver(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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,12 @@ There are several ways to work with Firefox profiles

<div>
{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" >}}
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile);
driver = new RemoteWebDriver(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();
Expand Down

0 comments on commit 9060cb9

Please sign in to comment.