How to use the toolium.driver_wrapper.DriverWrappersPool function in toolium

To help you get started, we’ve selected a few toolium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Telefonica / toolium / toolium / pageobjects / mobile_page_object.py View on Github external
def __new__(cls, driver_wrapper=None):
        """Instantiate android or ios page object from base page object depending on driver configuration

        Base, Android and iOS page objects must be defined with following structure:
            FOLDER/base/MODULE_NAME.py
                class BasePAGE_OBJECT_NAME(MobilePageObject)
            FOLDER/android/MODULE_NAME.py
                class AndroidPAGE_OBJECT_NAME(BasePAGE_OBJECT_NAME)
            FOLDER/ios/MODULE_NAME.py
                class IosPAGE_OBJECT_NAME(BasePAGE_OBJECT_NAME)

        :param driver_wrapper: driver wrapper instance
        :returns: android or ios page object instance
        """
        if cls.__name__.startswith('Base'):
            __driver_wrapper = driver_wrapper if driver_wrapper else DriverWrappersPool.get_default_wrapper()
            __os_name = 'ios' if __driver_wrapper.is_ios_test() else 'android'
            __class_name = cls.__name__.replace('Base', __os_name.capitalize())
            try:
                return getattr(importlib.import_module(cls.__module__), __class_name)(__driver_wrapper)
            except AttributeError:
                __module_name = cls.__module__.replace('.base.', '.{}.'.format(__os_name))
                return getattr(importlib.import_module(__module_name), __class_name)(__driver_wrapper)
        else:
            return super(MobilePageObject, cls).__new__(cls)
github Telefonica / toolium / toolium / behave / environment.py View on Github external
:param scenario: running scenario
    """
    # Configure reset properties from behave tags
    if 'no_reset_app' in scenario.tags:
        os.environ["AppiumCapabilities_noReset"] = 'true'
        os.environ["AppiumCapabilities_fullReset"] = 'false'
    elif 'reset_app' in scenario.tags:
        os.environ["AppiumCapabilities_noReset"] = 'false'
        os.environ["AppiumCapabilities_fullReset"] = 'false'
    elif 'full_reset_app' in scenario.tags:
        os.environ["AppiumCapabilities_noReset"] = 'false'
        os.environ["AppiumCapabilities_fullReset"] = 'true'

    # Force to reset driver before each scenario if it has @reset_driver tag
    if 'reset_driver' in scenario.tags:
        DriverWrappersPool.stop_drivers()
        DriverWrappersPool.download_videos('multiple tests', context.global_status['test_passed'])
        DriverWrappersPool.save_all_ggr_logs('multiple tests', context.global_status['test_passed'])
        DriverWrappersPool.remove_drivers()
        context.global_status['test_passed'] = True

    # Skip android_only or ios_only scenarios
    if 'android_only' in scenario.tags and context.driver_wrapper.is_ios_test():
        scenario.skip('Android scenario')
        return
    elif 'ios_only' in scenario.tags and context.driver_wrapper.is_android_test():
        scenario.skip('iOS scenario')
        return

    # Read @no_driver tag
    no_driver = 'no_driver' in scenario.tags or 'no_driver' in scenario.feature.tags
github Telefonica / toolium / toolium / behave / environment.py View on Github external
def create_and_configure_wrapper(context_or_world):
    """Create and configure driver wrapper in behave or lettuce tests

    :param context_or_world: behave context or lettuce world
    """
    # Create default driver wrapper
    context_or_world.driver_wrapper = DriverWrappersPool.get_default_wrapper()
    context_or_world.utils = context_or_world.driver_wrapper.utils

    # Get behave userdata properties to override config properties
    try:
        behave_properties = context_or_world.config.userdata
    except AttributeError:
        behave_properties = None

    # Configure wrapper
    context_or_world.driver_wrapper.configure(context_or_world.config_files, behave_properties=behave_properties)

    # Copy config object
    context_or_world.toolium_config = context_or_world.driver_wrapper.config

    # Configure logger
    context_or_world.logger = logging.getLogger(__name__)
github Telefonica / toolium / toolium / pageelements / page_elements.py View on Github external
If parent is not None, find_elements will be performed over it, instead of
        using the driver's method, so it can find nested elements.

        :param by: locator type
        :param value: locator value
        :param parent: parent element (WebElement, PageElement or locator tuple)
        :param order: index value if the locator returns more than one element
        :param page_element_class: class of page elements (PageElement, Button...)
        :param shadowroot: CSS SELECTOR of JS element where shadowroot tag appears
        """
        super(PageElements, self).__init__()
        self.locator = (by, value)  #: tuple with locator type and locator value
        self.parent = parent  #: element from which to find actual elements
        self.order = order  #: index value if the locator returns more than one element
        self.shadowroot = None  #: Not implemented for PageElements yet
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()  #: driver wrapper instance
        # update instance element class or use PageElement class
        if page_element_class:
            self.page_element_class = page_element_class
        self._page_elements = []
        self.reset_object(self.driver_wrapper)
github Telefonica / toolium / toolium / pageelements / group_page_element.py View on Github external
:param by: locator type
        :param value: locator value
        :param parent: parent element (WebElement, PageElement or locator tuple)
        :param driver_wrapper: driver wrapper instance
        :param order: index value if the locator returns more than one element
        :param wait: True if the page element must be loaded in wait_until_loaded method of the container page object
        :param shadowroot: CSS SELECTOR of JS element where shadowroot tag appears
        """
        self.logger = logging.getLogger(__name__)  #: logger instance
        self.locator = (by, value)  #: tuple with locator type and locator value
        self.parent = parent  #: element from which to find actual elements
        self.order = order  #: index value if the locator returns more than one element
        self.wait = wait  #: True if it must be loaded in wait_until_loaded method of the container page object
        self.shadowroot = None  #: Not implemented for Group yet
        self.driver_wrapper = driver_wrapper if driver_wrapper else \
            DriverWrappersPool.get_default_wrapper()  #: driver wrapper instance
        self.init_page_elements()
        self.reset_object(self.driver_wrapper)
github Telefonica / toolium / toolium / pageobjects / page_object.py View on Github external
def __init__(self, driver_wrapper=None, wait=False):
        """Initialize page object properties and update their page elements

        :param driver_wrapper: driver wrapper instance
        :param wait: True if the page object must be loaded in wait_until_loaded method of the container page object
        """
        super(PageObject, self).__init__()
        self.wait = wait  #: True if it must be loaded in wait_until_loaded method of the container page object
        self.driver_wrapper = driver_wrapper if driver_wrapper else \
            DriverWrappersPool.get_default_wrapper()  #: driver wrapper instance
        self.init_page_elements()
        self.reset_object(self.driver_wrapper)
github Telefonica / toolium / toolium / pageelements / page_element.py View on Github external
using the driver's method, so it can find nested elements.

        :param by: locator type
        :param value: locator value
        :param parent: parent element (WebElement, PageElement or locator tuple)
        :param order: index value if the locator returns more than one element
        :param wait: True if the page element must be loaded in wait_until_loaded method of the container page object
        :param shadowroot: CSS SELECTOR of JS element where shadowroot tag appears
        """
        super(PageElement, self).__init__()
        self.locator = (by, value)  #: tuple with locator type and locator value
        self.parent = parent  #: element from which to find actual elements
        self.order = order  #: index value if the locator returns more than one element
        self.wait = wait  #: True if it must be loaded in wait_until_loaded method of the container page object
        self.shadowroot = shadowroot  #: CSS SELECTOR of the shadowroot for encapsulated element
        self.driver_wrapper = DriverWrappersPool.get_default_wrapper()  #: driver wrapper instance
        self.reset_object(self.driver_wrapper)
github Telefonica / toolium / toolium / behave / environment.py View on Github external
:param context: behave context
    """
    # Use pytest asserts if behave_pytest is installed
    install_pytest_asserts()

    # Get 'Config_environment' property from user input (e.g. -D Config_environment=ios)
    env = context.config.userdata.get('Config_environment')
    # Deprecated: Get 'env' property from user input (e.g. -D env=ios)
    env = env if env else context.config.userdata.get('env')
    if env:
        os.environ['Config_environment'] = env

    if not hasattr(context, 'config_files'):
        context.config_files = ConfigFiles()
    context.config_files = DriverWrappersPool.initialize_config_files(context.config_files)

    # By default config directory is located in environment path
    if not context.config_files.config_directory:
        context.config_files.set_config_directory(DriverWrappersPool.get_default_config_directory())

    context.global_status = {'test_passed': True}
    create_and_configure_wrapper(context)

    # Behave dynamic environment
    context.dyn_env = DynamicEnvironment(logger=context.logger)