-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[py] Server class to manage (download/run) grid server #15666
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
[py] Server class to manage (download/run) grid server #15666
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to ef6a261
Previous suggestions✅ Suggestions up to commit f49c500
|
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.
LGTM. Thank you @cgoldberg!
Does this pr need a similar change: def grid_path(required_version)
command = [binary, '--grid']
command << required_version if required_version
location = run(*command)
WebDriver.logger.debug("Grid found at #{location}", id: :selenium_manager)
Platform.assert_file location
location
end
private
def generate_command(binary, options)
command = [binary, '--browser', options.browser_name, '--output', 'json']
command = [binary, '--browser', options.browser_name]
if options.browser_version
command << '--browser-version'
command << options.browser_version
@@ -65,7 +76,6 @@ def generate_command(binary, options)
command << '--proxy'
(command << options.proxy.ssl) || options.proxy.http
end
command << '--debug' if WebDriver.logger.debug?
command
end
@@ -98,6 +108,8 @@ def binary
end
def run(*command)
command += %w[--output json]
command << '--debug' if WebDriver.logger.debug?
WebDriver.logger.debug("Executing Process #{command}", id: :selenium_manager)
begin from to be fully functional? Or is the functionality to download the grid .jar file already built into Selenium Manager w/ the --grid command? Similarly, since if I'm not mistaken, the CI has the .jar file included, should we add a test for this download functionality? |
Have a few questions and will re-review after
Yes, exactly... with this:
Calling that with the
CI already has the jar, so it is configured to just use that one.
Probably. I was going to add some unit tests with everything mocked, so it wouldn't actually download, just make sure everything was called correctly. But I can add an integration test where it actually downloads the .jar and verifies it on disk. |
Perfect, great work! |
Ah, I see why I was confused - I thought |
The Ruby version of this implements more options. Not sure if they are all necessary, I will say that being able to toggle the logging level for tests is nice when debugging. |
I added a new There are 2 minor concerns:
I don't think either of these are a big deal, but thought I would point them out. |
I'll add |
Also for reference, the Ruby tests start the server like this: The idea is that if you're running without bazel it will download it, and running with bazel it will use what bazel built |
I added the |
That sounds better. The way it works in the Python tests is that it always looks for what bazel built.. so if you don't build grid with bazel first, it will just fail. I'll add that to conftest.py |
User description
🔗 Related Issues
This is the Python implementation for #12305
💥 What does this PR do?
This PR adds a new
selenium.webdriver.remote.server
module with aServer
class. It is used for downloading/starting/stopping the grid server in standalone mode.It uses Selenium Manager to download and locate the server jar file. To use the
start()
method, you must have a Java JRE on your system (or it will give you an error message).This also updates the PyTest configuration (
py/conftest.py
) to use this class to replace the code for launching the server for remote tests. It uses the existing local server instead of downloading one, since it is already built locally and CI is setup to use it.Example usage:
More examples:
💡 Additional Considerations
I added some unit tests, but they aren't comprehensive because it's a pain to mock selenium manager and the subprocess call... I'll figure that out later.
🔄 Types of changes
PR Type
Enhancement, Tests
Description
Introduces
Server
class for managing Selenium Grid server.Refactors pytest fixture to use new
Server
class for remote tests.Adds unit tests for
Server
class error handling and validation.Updates API documentation to include new
server
module.Changes walkthrough 📝
server.py
Add Server class for Selenium Grid server management
py/selenium/webdriver/remote/server.py
Server
class for managing Selenium Grid server lifecycle.conftest.py
Refactor pytest server fixture to use Server class
py/conftest.py
Server
class.remote_server_tests.py
Add unit tests for Server class validation
py/test/unit/selenium/webdriver/remote/remote_server_tests.py
Server
class input validation and error handling.api.rst
Document remote.server module in API docs
py/docs/source/api.rst
selenium.webdriver.remote.server
module in APIreference.