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

Optimize DysonModule class #12

Open
ddavison opened this issue May 25, 2018 · 0 comments
Open

Optimize DysonModule class #12

ddavison opened this issue May 25, 2018 · 0 comments

Comments

@ddavison
Copy link
Member

ddavison commented May 25, 2018

In each class that inherits from DysonModule, is still required to have a decent chunk of code.

from dyson.errors import DysonError
from dyson.utils.module import DysonModule
from dyson.utils.selectors import translate_selector


class ClickModule(DysonModule):
    def run(self, webdriver, params):
        """
        Click an element on the page
        :param webdriver:
        :param params:
        :return:
        """
        if len(params.keys()) > 0:
            selector, strategy = translate_selector(params, webdriver)

            if selector and strategy:
                return selector(strategy).click()
            else:
                raise DysonError("You need to specify a valid selector to click")
        else:
            raise DysonError("You need to specify an argument to \"click\"")

we could optimize this by creating some sort of get_param('param') and have it throw errors or return. we could even have it default . get_param('param', 'default')

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

No branches or pull requests

1 participant