Skip to content

[java][py]: move java and python firefox profile code #2090

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 1 commit into from
Dec 2, 2024
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
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
Loading