Skip to content

Optimize DysonModule class #12

@ddavison

Description

@ddavison

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions