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

Implement plugin system #841

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsfehler
Copy link
Collaborator

@jsfehler jsfehler commented Nov 4, 2020

This solution uses Pluggy https://pluggy.readthedocs.io/en/latest/ to add a plugin system into Splinter.

This PR features hooks for:

Plugins classes or modules can be registered via a call to splinter.plugins.register()

This PR is missing:

  • Hooks implementation for non-webdriver drivers
  • Documentation

But will be added if the overall approach works.

@jsfehler
Copy link
Collaborator Author

jsfehler commented Nov 4, 2020

This is a bare bones example of what an external driver plugin could look like:


import splinter
from splinter.driver.webdriver import BaseWebDriver


class WebDriver(BaseWebDriver):
    driver_name = "Ie"

    def __init__(self, wait_time=2):
        self.driver = Ie()

        super(WebDriver, self).__init__(wait_time)


class InternetExplorerPlugin:
    @splinter.hookimpl
    def splinter_prepare_drivers(drivers):
        drivers['internet_explorer'] = WebDriver


splinter.plugins.register(InternetExplorerPlugin())

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.

1 participant