Skip to content

Implement plugin system#841

Open
jsfehler wants to merge 1 commit into
cobrateam:masterfrom
jsfehler:plugin_manager
Open

Implement plugin system#841
jsfehler wants to merge 1 commit into
cobrateam:masterfrom
jsfehler:plugin_manager

Conversation

@jsfehler

@jsfehler jsfehler commented Nov 4, 2020

Copy link
Copy Markdown
Collaborator

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

jsfehler commented Nov 4, 2020

Copy link
Copy Markdown
Collaborator Author

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