Example #1
0
    def wait_till_element_is_clickable(self, css_selector, wait_time=DEFAULT_TIMEOUT, message=None):
        css_selector_key = get_css_selector_key(css_selector)
        default_error_message = 'Element ({}) does not get clickable in {} seconds. css selector: \'{}\''.format(
            css_selector_key, str(wait_time), css_selector)

        error_message = message or default_error_message

        WebDriverWait(self.driver, wait_time).until(
            EC.element_to_be_clickable((By.CSS_SELECTOR, css_selector)), message=error_message)
Example #2
0
    def wait_till_all_elements_visible(self, css_selector, wait_time=DEFAULT_TIMEOUT, message=None):
        css_selector_key = get_css_selector_key(css_selector)
        default_error_message = 'No element ({}) get visible in {} seconds. css selector: \'{}\''.format(
            css_selector_key, str(wait_time), css_selector)

        error_message = message or default_error_message

        WebDriverWait(self.driver, wait_time).until(
            EC.presence_of_all_elements_located((By.CSS_SELECTOR, css_selector)), message=error_message)
Example #3
0
    def wait_till_text_appeared(self, css_selector, wait_time=DEFAULT_TIMEOUT, message=None):
        css_selector_key = get_css_selector_key(css_selector)
        default_error_message = 'No text is attached in the element ({}) in {} seconds. css selector: \'{}\''.format(
            css_selector_key, str(wait_time), css_selector)

        error_message = message or default_error_message

        WebDriverWait(self.driver, wait_time).until_not(
            EC.absence_of_text_in_element_located((By.CSS_SELECTOR, css_selector)), message=error_message)
Example #4
0
    def wait_till_element_is_present(self, css_selector, wait_time=DEFAULT_TIMEOUT, message=None):
        css_selector_key = get_css_selector_key(css_selector)
        default_error_message = 'Element ({}) is not attached in DOM in {} seconds. css selector: \'{}\''.format(
            css_selector_key, str(wait_time), css_selector)

        error_message = message or default_error_message

        WebDriverWait(self.driver, wait_time).until(
            EC.presence_of_element_located((By.CSS_SELECTOR, css_selector)), message=error_message)
Example #5
0
    def wait_till_length_equals(self, css_selector, expected_length, wait_time=DEFAULT_TIMEOUT,
                                message=None):
        css_selector_key = get_css_selector_key(css_selector)
        default_error_message = 'Number of elements ({}) is not equal to {}. css selector: \'{}\''.format(
            css_selector_key, str(expected_length), css_selector)

        error_message = message or default_error_message

        WebDriverWait(self.driver, wait_time).until(
            EC.elements_have_exact_count((By.CSS_SELECTOR, css_selector), expected_length), message=error_message)
Example #6
0
    def wait_till_text_contains(self, css_selector, expected_text, wait_time=DEFAULT_TIMEOUT, message=None):
        css_selector_key = get_css_selector_key(css_selector)
        default_error_message = 'Text in the element ({}) does not contain \'{}\'. css selector: \'{}\''.format(
            css_selector_key, expected_text, css_selector)

        error_message = message or default_error_message

        WebDriverWait(self.driver, wait_time).until(
            EC.text_to_be_present_in_element((By.CSS_SELECTOR, css_selector), expected_text, ignore_case=True),
            message=error_message)