-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use pytest fixtures to setup browser, split up chrome and firefox jobs
- Loading branch information
Showing
18 changed files
with
207 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/tests_firefox_webdriver/test_firefox_capabilities.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def browser_kwargs(): | ||
return {"capabilities": {"pageLoadStrategy": "eager"}} | ||
|
||
|
||
def test_capabilities_set(request, browser): | ||
request.addfinalizer(browser.quit) | ||
|
||
capabilities = browser.driver.capabilities | ||
assert "pageLoadStrategy" in capabilities | ||
assert "eager" == capabilities.get("pageLoadStrategy") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import pathlib | ||
|
||
import pytest | ||
|
||
from tests.fake_webapp import EXAMPLE_APP | ||
|
||
from splinter.config import Config | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def browser_config(): | ||
extension_path = pathlib.Path( | ||
os.getcwd(), # NOQA PTH109 | ||
"tests", | ||
"dummy_extension", | ||
"borderify-1.0-an+fx.xpi", | ||
) | ||
|
||
return Config(extensions=[str(extension_path)], headless=True) | ||
|
||
|
||
def test_firefox_create_instance_with_extension(request, browser): | ||
"""Test: Load an extension via selenium. | ||
The dummy extension should add a red border to any web page. | ||
""" | ||
request.addfinalizer(browser.quit) | ||
|
||
browser.visit(EXAMPLE_APP) | ||
|
||
elem = browser.find_by_css("body") | ||
elem.is_visible(wait_time=20) | ||
|
||
style = elem._element.get_attribute("style") | ||
assert "border: 5px solid red;" == style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def browser_kwargs(): | ||
prefs = { | ||
"profile_preferences": { | ||
"dom.max_script_run_time": 213, | ||
"devtools.inspector.enabled": True, | ||
}, | ||
} | ||
return prefs | ||
|
||
|
||
def test_preference_set(request, browser): | ||
request.addfinalizer(browser.quit) | ||
|
||
# Rip the preferences out of firefox's config page | ||
browser.visit("about:config") | ||
browser.find_by_id("warningButton").click() | ||
browser.find_by_id("about-config-search").fill("dom.max_script_run_time") | ||
elem = browser.find_by_xpath("//table[@id='prefs']/tr[1]/td[1]/span/span") | ||
assert elem.value == "213" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.