How to use the seleniumbase.config.settings.SMALL_TIMEOUT function in seleniumbase

To help you get started, we’ve selected a few seleniumbase 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 seleniumbase / SeleniumBase / seleniumbase / fixtures / js_utils.py View on Github external
def wait_for_css_query_selector(
        driver, selector, timeout=settings.SMALL_TIMEOUT):
    element = None
    start_ms = time.time() * 1000.0
    stop_ms = start_ms + (timeout * 1000.0)
    for x in range(int(timeout * 10)):
        try:
            selector = re.escape(selector)
            selector = escape_quotes_if_needed(selector)
            element = driver.execute_script(
                """return document.querySelector('%s')""" % selector)
            if element:
                return element
        except Exception:
            element = None
        if not element:
            now_ms = time.time() * 1000.0
            if now_ms >= stop_ms:
github seleniumbase / SeleniumBase / seleniumbase / core / settings_parser.py View on Github external
continue
        elif value == "True":
            override_settings[key] = True
        elif value == "False":
            override_settings[key] = False
        elif len(value) > 1 and value.startswith('"') and value.endswith('"'):
            override_settings[key] = value[1:-1]
        elif len(value) > 1 and value.startswith("'") and value.endswith("'"):
            override_settings[key] = value[1:-1]
        else:
            continue

        if key == "MINI_TIMEOUT":
            settings.MINI_TIMEOUT = override_settings[key]
        elif key == "SMALL_TIMEOUT":
            settings.SMALL_TIMEOUT = override_settings[key]
        elif key == "LARGE_TIMEOUT":
            settings.LARGE_TIMEOUT = override_settings[key]
        elif key == "EXTREME_TIMEOUT":
            settings.EXTREME_TIMEOUT = override_settings[key]
        elif key == "ARCHIVE_EXISTING_LOGS":
            settings.ARCHIVE_EXISTING_LOGS = override_settings[key]
        elif key == "ARCHIVE_EXISTING_DOWNLOADS":
            settings.ARCHIVE_EXISTING_DOWNLOADS = override_settings[key]
        elif key == "SCREENSHOT_NAME":
            settings.SCREENSHOT_NAME = override_settings[key]
        elif key == "BASIC_INFO_NAME":
            settings.BASIC_INFO_NAME = override_settings[key]
        elif key == "PAGE_SOURCE_NAME":
            settings.PAGE_SOURCE_NAME = override_settings[key]
        elif key == "LATEST_REPORT_DIR":
            settings.LATEST_REPORT_DIR = override_settings[key]
github seleniumbase / SeleniumBase / seleniumbase / fixtures / page_actions.py View on Github external
def hover_and_click(driver, hover_selector, click_selector,
                    hover_by=By.CSS_SELECTOR, click_by=By.CSS_SELECTOR,
                    timeout=settings.SMALL_TIMEOUT):
    """
    Fires the hover event for a specified element by a given selector, then
    clicks on another element specified. Useful for dropdown hover based menus.
    @Params
    driver - the webdriver object (required)
    hover_selector - the css selector to hover over (required)
    click_selector - the css selector to click on (required)
    hover_by - the hover selector type to search by (Default: By.CSS_SELECTOR)
    click_by - the click selector type to search by (Default: By.CSS_SELECTOR)
    timeout - number of seconds to wait for click element to appear after hover
    """
    start_ms = time.time() * 1000.0
    stop_ms = start_ms + (timeout * 1000.0)
    element = driver.find_element(by=hover_by, value=hover_selector)
    hover = ActionChains(driver).move_to_element(element)
    hover.perform()
github seleniumbase / SeleniumBase / seleniumbase / fixtures / base_case.py View on Github external
    def switch_to_frame(self, frame, timeout=settings.SMALL_TIMEOUT):
        """ Sets driver control to the specified browser frame. """
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        page_actions.switch_to_frame(self.driver, frame, timeout)
github seleniumbase / SeleniumBase / seleniumbase / fixtures / base_case.py View on Github external
def __jquery_click(self, selector, by=By.CSS_SELECTOR):
        """ Clicks an element using jQuery. Different from using pure JS. """
        selector, by = self.__recalculate_selector(selector, by)
        self.wait_for_element_present(
            selector, by=by, timeout=settings.SMALL_TIMEOUT)
        if self.is_element_visible(selector, by=by):
            self.__demo_mode_highlight_if_active(selector, by)
        selector = self.convert_to_css_selector(selector, by=by)
        selector = self.__make_css_match_first_element_only(selector)
        click_script = """jQuery('%s')[0].click()""" % selector
        self.safe_execute_script(click_script)
github seleniumbase / SeleniumBase / seleniumbase / fixtures / base_case.py View on Github external
def click(self, selector, by=By.CSS_SELECTOR,
              timeout=settings.SMALL_TIMEOUT):
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        if page_utils.is_xpath_selector(selector):
            by = By.XPATH
        if page_utils.is_link_text_selector(selector):
            selector = page_utils.get_link_text_from_selector(selector)
            by = By.LINK_TEXT
            if not self.is_link_text_visible(selector):
                # Handle a special case of links hidden in dropdowns
                self.click_link_text(selector, timeout=timeout)
                return
        element = page_actions.wait_for_element_visible(
            self.driver, selector, by, timeout=timeout)
        self.__demo_mode_highlight_if_active(selector, by)
        if not self.demo_mode:
            self.__scroll_to_element(element)
github seleniumbase / SeleniumBase / seleniumbase / core / tour_helper.py View on Github external
if interval < 0.5:
            interval = 0.5

    if not is_hopscotch_activated(driver):
        activate_hopscotch(driver)

    if len(tour_steps[name]) > 1:
        try:
            if "target: " in tour_steps[name][1]:
                selector = re.search(
                    r"[\S\s]+target: '([\S\s]+)',[\S\s]+title: '",
                    tour_steps[name][1]).group(1)
                selector = selector.replace('\\', '').replace(':first', '')
                page_actions.wait_for_element_present(
                    driver, selector, by=By.CSS_SELECTOR,
                    timeout=settings.SMALL_TIMEOUT)
            else:
                selector = "html"
        except Exception:
            js_utils.post_messenger_error_message(
                driver, "Tour Error: {'%s'} was not found!" % selector,
                msg_dur)
            raise Exception(
                "Tour Error: {'%s'} was not found! "
                "Exiting due to failure on first tour step!"
                "" % selector)

    driver.execute_script(instructions)
    tour_on = True
    if autoplay:
        start_ms = time.time() * 1000.0
        stop_ms = start_ms + (interval * 1000.0)
github seleniumbase / SeleniumBase / seleniumbase / fixtures / base_case.py View on Github external
    def switch_to_window(self, window, timeout=settings.SMALL_TIMEOUT):
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        page_actions.switch_to_window(self.driver, window, timeout)
github seleniumbase / SeleniumBase / seleniumbase / fixtures / page_actions.py View on Github external
def switch_to_window(driver, window, timeout=settings.SMALL_TIMEOUT):
    """
    Wait for a window to appear, and switch to it. This should be usable
    as a drop-in replacement for driver.switch_to.window().
    @Params
    driver - the webdriver object (required)
    window - the window index or window handle
    timeout - the time to wait for the window in seconds
    """
    start_ms = time.time() * 1000.0
    stop_ms = start_ms + (timeout * 1000.0)
    if isinstance(window, int):
        for x in range(int(timeout * 10)):
            try:
                window_handle = driver.window_handles[window]
                driver.switch_to.window(window_handle)
                return True
github seleniumbase / SeleniumBase / seleniumbase / fixtures / base_case.py View on Github external
def jquery_click(self, selector, by=By.CSS_SELECTOR):
        """ Clicks an element using jQuery. Different from using pure JS. """
        selector, by = self.__recalculate_selector(selector, by)
        self.wait_for_element_present(
            selector, by=by, timeout=settings.SMALL_TIMEOUT)
        if self.is_element_visible(selector, by=by):
            self.__demo_mode_highlight_if_active(selector, by)
        selector = self.convert_to_css_selector(selector, by=by)
        selector = self.__make_css_match_first_element_only(selector)
        click_script = """jQuery('%s')[0].click()""" % selector
        self.safe_execute_script(click_script)
        self.__demo_mode_pause_if_active()