Ejemplo n.º 1
0
    def is_text_not_visible(self, text: str) -> bool:
        """Boolean check for if a node with specific text does not exist and is not visible.

        :usage example: driver.is_text_not_visible('Forgot password?')

        :param text: The specific text within a node.
        """
        try:
            (self.find_element(*Selectors.text(text))
             and self.find_element(*Selectors.text(text)).is_displayed())
            return False
        except NoSuchElementException:
            return True
        except ValueError:
            return True
Ejemplo n.º 2
0
    def test__text(self, test_var: fixture) -> None:
        """Check the output of a text Selector.

        :param test_var: A string for testing.
        """
        selector: Selector = Selectors.text(test_var)

        assert selector == ('xpath', f'//*[contains(text(), "{test_var}")]')
Ejemplo n.º 3
0
    def wait_until_text_visible(self,
                                text: str,
                                wait_time: int = None) -> Union[Element, None]:
        """Wait until a text string is visible, then return the element for further actions.

        :usage example:
            driver.wait_until_text_visible('Joe Schmo')

        :param text: The specific text string.
        :param wait_time: The amount of time until a TimeoutException occurs.
        """
        _wait: int = wait_time if wait_time is not None else (self.wait_time //
                                                              2)

        try:
            return WebDriverWait(self, _wait).until(
                Conditions.VisibilityOfElementLocated(
                    (Selectors.text(text)[0], Selectors.text(text)[1]),
                    _wait,
                ), )
        except WebDriverException:
            return None
Ejemplo n.º 4
0
    def wait_until_text_not_visible(self,
                                    text: str,
                                    wait_time: int = None) -> bool:
        """Wait until a text string is not visible, then return a boolean value.

        :usage example:
            driver.find_element(*Selectors.data_id(
                    'ride-card-container')).wait_until_text_not_visible('Joe Schmo')

        :param text: The specific text string.
        :param wait_time: The amount of time until a TimeoutException occurs.
        """
        _wait: int = wait_time if wait_time is not None else (self.wait_time //
                                                              2)

        try:
            return WebDriverWait(self, _wait).until_not(
                Conditions.VisibilityOfElementLocated(
                    (Selectors.text(text)[0], Selectors.text(text)[1]),
                    _wait,
                ), )
        except WebDriverException:
            return False
Ejemplo n.º 5
0
    def is_text_present(self, text: str) -> bool:
        """Boolean check for if a node with specific text exists.

        :usage example: driver.is_text_present('Forgot password?')

        :param text: The specific text within a node.
        """
        try:
            self.find_element(*Selectors.text(text))
            return True
        except NoSuchElementException:
            return False
        except ValueError:
            return False