Пример #1
0
    def start_driver(self):
        """
        Start web driver session by referring driver capabilities for AUT.

        Returns:
            None
        """
        if BaseDriver.__driver is not None:
            self.stop_driver()

        default_browser = ConfigurationsManager().get_str_for_key(
            ApplicationProperties.DRIVER_NAME)
        if 'appium' in default_browser.lower():
            self.__start_appium_webdriver()
        elif 'lambda' in default_browser.lower():
            self.__start_lambda_webdriver()
        else:
            self.__start_webdriver()
Пример #2
0
    def __start_webdriver(self):
        driver_name = ConfigurationsManager().get_str_for_key(
            ApplicationProperties.DRIVER_NAME)
        driver_name = str(driver_name).lower()
        driver_capabilities = ConfigurationsManager().get_str_for_key(
            driver_name[:driver_name.index('driver')] +
            '.additional.capabilities')

        if driver_capabilities is not None and 'driverClass' in driver_capabilities:
            class_name = driver_capabilities['driverClass']
        else:
            class_name = 'selenium.webdriver.{driver_name}.webdriver.WebDriver'. \
                format(driver_name=driver_name[:driver_name.index('driver')])

        driver_name_value = ConfigurationsManager().get_str_for_key(
            ApplicationProperties.DRIVER_NAME)
        if driver_name_value.lower() == 'chromedriver':
            execPath = ConfigurationsManager().get_str_for_key(
                ApplicationProperties.CHROME_DRIVER_PATH)
        else:
            execPath = ConfigurationsManager().get_str_for_key(
                ApplicationProperties.GECKO_DRIVER_PATH)
        selenium_server = ConfigurationsManager().get_str_for_key(
            ApplicationProperties.REMOTE_SERVER)
        selenium_port = ConfigurationsManager().get_str_for_key(
            ApplicationProperties.REMOTE_PORT)
        command_executor = selenium_server + selenium_port + "/wd/hub"

        if driver_capabilities is None:
            driver_class = load_class(class_name)()
        elif "remote" in ConfigurationsManager().get_str_for_key(
                ApplicationProperties.DRIVER_NAME).lower():
            print("capabilities : ")
            print(json.loads(driver_capabilities))
            driver_class = load_class(class_name)(
                command_executor=command_executor,
                desired_capabilities=json.loads(driver_capabilities))
        else:
            driver_class = load_class(class_name)(
                executable_path=execPath,
                desired_capabilities=json.loads(driver_capabilities))
        env_base_url = ConfigurationsManager().get_str_for_key(
            ApplicationProperties.SELENIUM_BASE_URL)
        BaseDriver.__driver = pafwebdriver.PAFWebDriver(driver_class)
        BaseDriver.__driver.get(env_base_url)
        BaseDriver.__driver.implicitly_wait(
            ConfigurationsManager().get_str_for_key(
                ApplicationProperties.SELENIUM_WAIT_TIMEOUT))