def _is_page_not_reachable(browser: Browser) -> bool: """Returns `True` if web page is not reachable due to networking issue otherwise `False`. Args: browser: a current browser session """ try: return WebElement.find(browser).by_class("neterror").is_displayed() except NoSuchElementException: return False
def send_message(self, message: str) -> None: WebElement.find(self._browser).by_class("js-message").set(message, clear=True) WebElement.find(self._browser).by_class("js-send-message").click() self._match().wait_for_disappear(2) WebElement.find( self._browser).by_class("confirmation").wait_for_disappear(2)
def like(self) -> None: WebElement.find( self._browser).by_class("profile-action--color-yes").click() try: WebElement.find(self._browser).by_class( "js-chrome-pushes-deny").wait_for_visibility(2).click() WebElement.find( self._browser).by_class("ovl__content").wait_for_disappear(5) except TimeoutException: pass if self._is_out_of_votes(): raise BadooError("Sorry! You've hit the vote limit!")
def is_login_failed(self) -> bool: try: return (WebElement.find( self._browser).by_class("new-form__error").is_displayed()) except NoSuchElementException: return False
def login(self, username: str, password: str) -> None: WebElement.find( self._browser).by_class("js-signin-login").set(username) WebElement.find( self._browser).by_class("js-signin-password").set(password) WebElement.find(self._browser).by_css("button[type='submit']").click()
def _is_out_of_votes(self) -> bool: try: return (WebElement.find(self._browser).by_class( "ovl__hint").wait_for_visibility(1).is_displayed()) except TimeoutException: return False
def _match(self) -> Element: return WebElement.find(self._browser).by_class("ovl-match")
def _is_blocker_visible(self) -> bool: try: return (WebElement.find(self._browser).by_class( "ovl").wait_for_visibility(1).is_displayed()) except TimeoutException: return False