-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Generic executor that uses WebDriver protocol directly #10197
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
710e8e5
runs testharness
kereliuk 7584562
runs testharness
kereliuk a858927
remove stdout
kereliuk 896637a
fix errors, add client timeout set
kereliuk 094d1c4
clean up and fix typo
kereliuk 9991114
fix typo
kereliuk 3c16faa
fix capabilities and IWYU
kereliuk ab0d442
remove whitespace
kereliuk faf34a2
address jgraham comments
kereliuk 880ac93
added chrome_webdriver as a product
kereliuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
|
||
product_list = ["chrome", | ||
"chrome_android", | ||
"chrome_webdriver", | ||
"edge", | ||
"firefox", | ||
"ie", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
from .base import Browser, ExecutorBrowser, require_arg | ||
from ..webdriver_server import ChromeDriverServer | ||
from ..executors import executor_kwargs as base_executor_kwargs | ||
from ..executors.executorselenium import (SeleniumTestharnessExecutor, | ||
SeleniumRefTestExecutor) | ||
from ..executors.executorwebdriver import (WebDriverTestharnessExecutor, | ||
WebDriverRefTestExecutor) | ||
from ..executors.executorchrome import ChromeDriverWdspecExecutor | ||
|
||
|
||
__wptrunner__ = {"product": "chrome_webdriver", | ||
"check_args": "check_args", | ||
"browser": "ChromeWebdriverBrowser", | ||
"executor": {"testharness": "WebDriverTestharnessExecutor", | ||
"reftest": "WebDriverRefTestExecutor", | ||
"wdspec": "ChromeDriverWdspecExecutor"}, | ||
"browser_kwargs": "browser_kwargs", | ||
"executor_kwargs": "executor_kwargs", | ||
"env_extras": "env_extras", | ||
"env_options": "env_options"} | ||
|
||
def check_args(**kwargs): | ||
require_arg(kwargs, "webdriver_binary") | ||
|
||
|
||
def browser_kwargs(test_type, run_info_data, **kwargs): | ||
return {"binary": kwargs["binary"], | ||
"webdriver_binary": kwargs["webdriver_binary"], | ||
"webdriver_args": kwargs.get("webdriver_args")} | ||
|
||
|
||
def executor_kwargs(test_type, server_config, cache_manager, run_info_data, | ||
**kwargs): | ||
from selenium.webdriver import DesiredCapabilities | ||
|
||
executor_kwargs = base_executor_kwargs(test_type, server_config, | ||
cache_manager, **kwargs) | ||
executor_kwargs["close_after_done"] = True | ||
capabilities = dict(DesiredCapabilities.CHROME.items()) | ||
capabilities.setdefault("chromeOptions", {})["prefs"] = { | ||
"profile": { | ||
"default_content_setting_values": { | ||
"popups": 1 | ||
} | ||
} | ||
} | ||
for (kwarg, capability) in [("binary", "binary"), ("binary_args", "args")]: | ||
if kwargs[kwarg] is not None: | ||
capabilities["chromeOptions"][capability] = kwargs[kwarg] | ||
if test_type == "testharness": | ||
capabilities["chromeOptions"]["useAutomationExtension"] = False | ||
capabilities["chromeOptions"]["excludeSwitches"] = ["enable-automation"] | ||
if test_type == "wdspec": | ||
capabilities["chromeOptions"]["w3c"] = True | ||
|
||
capabilities["chromeOptions"]["w3c"] = True | ||
always_match = {"alwaysMatch": capabilities} | ||
executor_kwargs["capabilities"] = always_match | ||
return executor_kwargs | ||
|
||
|
||
def env_extras(**kwargs): | ||
return [] | ||
|
||
|
||
def env_options(): | ||
return {} | ||
|
||
|
||
class ChromeWebdriverBrowser(Browser): | ||
"""Chrome is backed by chromedriver, which is supplied through | ||
``wptrunner.webdriver.ChromeDriverServer``. | ||
""" | ||
|
||
def __init__(self, logger, binary, webdriver_binary="chromedriver", | ||
webdriver_args=None): | ||
"""Creates a new representation of Chrome. The `binary` argument gives | ||
the browser binary to use for testing.""" | ||
Browser.__init__(self, logger) | ||
self.binary = binary | ||
self.server = ChromeDriverServer(self.logger, | ||
binary=webdriver_binary, | ||
args=webdriver_args) | ||
|
||
def start(self, **kwargs): | ||
self.server.start(block=False) | ||
|
||
def stop(self, force=False): | ||
self.server.stop(force=force) | ||
|
||
def pid(self): | ||
return self.server.pid | ||
|
||
def is_alive(self): | ||
# TODO(ato): This only indicates the driver is alive, | ||
# and doesn't say anything about whether a browser session | ||
# is active. | ||
return self.server.is_alive() | ||
|
||
def cleanup(self): | ||
self.stop() | ||
|
||
def executor_browser(self): | ||
return ExecutorBrowser, {"webdriver_url": self.server.url} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this into the webdriver client rather than here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean, this is in tools/webdriver/webdriver/client.py which is the webdriver client?