Skip to content
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

Automate RemoteConnection subclass selection (1) #8010

Conversation

abdelrahman-t
Copy link
Contributor

@abdelrahman-t abdelrahman-t commented Feb 7, 2020

Select an appropriate RemoteConnection subclass based on specified
capabilities while instantiating WebDriver (aka Remote) class.

Add a new field "brower_name" to RemoteConnection class.
Field can be overridden in RemoteConnection subclasses
that wish to handle connections to specific browsers.

Related #7959

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Select an appropriate RemoteConnection subclass based on specified
capabilities while instantiating WebDriver (aka Remote) class.

Add a new field "brower_name" to RemoteConnection class.
Field can be overridden in RemoteConnection subclasses
that wish to handle connections to specific browsers.

Related SeleniumHQ#7959
@claassistantio
Copy link

claassistantio commented Feb 7, 2020

CLA assistant check
All committers have signed the CLA.

@abdelrahman-t
Copy link
Contributor Author

Alternate and more general implementation (but with some assumptions)

def get_remote_connection(capabilities, command_executor, keep_alive):
    # Following code assumes that all subclasses of RemoteConnection
    # has been loaded.
    candidates = [RemoteConnection] + RemoteConnection.__subclasses__()
    handler = next(
        (c for c in candidates if c.browser_name == capabilities.get('browserName')),
        RemoteConnection
    )

    return handler(command_executor, keep_alive=keep_alive)

@AutomatedTester AutomatedTester merged commit 3169619 into SeleniumHQ:master Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants