redash-ui-tests/pages/home.py

64 строки
1.9 KiB
Python
Исходник Постоянная ссылка Обычный вид История

2018-06-26 00:47:21 +03:00
# -*- coding: utf-8 -*-
"""Page model for home page."""
2018-06-28 15:44:28 +03:00
import typing
2018-06-26 00:47:21 +03:00
2018-06-28 15:44:28 +03:00
from pypom import Page
2018-06-26 00:47:21 +03:00
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as expected
2018-06-26 00:47:21 +03:00
2018-06-28 15:44:28 +03:00
from pages.queries import QueryPage
2018-06-28 16:08:32 +03:00
Locator = typing.Tuple[typing.Any, str]
2018-06-28 15:44:28 +03:00
2018-06-26 00:47:21 +03:00
class HomePage(Page):
"""Page object model for home page."""
2018-06-28 16:08:32 +03:00
_profile_username_dropdown_locator: Locator = (
By.CSS_SELECTOR,
".dropdown--profile__username",
)
_navbar_search_input_locator: Locator = (By.CLASS_NAME, "navbar__search__input")
_search_input_btn_locator: Locator = (By.CLASS_NAME, "input-group-btn .btn")
@property
2018-06-28 15:52:27 +03:00
def loaded(self) -> typing.Any:
2018-06-26 00:47:21 +03:00
self.wait.until(
lambda _: self.is_element_displayed(
*self._profile_username_dropdown_locator
2018-06-26 00:47:21 +03:00
)
)
return self
@property
2018-06-28 15:44:28 +03:00
def title(self) -> typing.Any:
"""Return the page title."""
return self.wait.until(lambda s: self.selenium.title)
@property
2018-06-28 15:44:28 +03:00
def profile_dropdown(self) -> typing.Any:
"""Return the profile dropdown element."""
element = self.wait.until(
expected.visibility_of_element_located(
self._profile_username_dropdown_locator
)
)
return element.text
2018-06-28 15:44:28 +03:00
def log_out(self) -> None:
element = self.selenium.find_element(*self._profile_username_dropdown_locator)
2018-06-26 00:47:21 +03:00
element.click()
logout = element.find_elements_by_tag_name("li")
logout[-1].click()
2018-06-28 15:44:28 +03:00
def search(self, term: str) -> typing.Any:
element = self.selenium.find_element(*self._navbar_search_input_locator)
2018-06-26 00:47:21 +03:00
element.click()
element.send_keys(term)
button = self.selenium.find_element(*self._search_input_btn_locator)
2018-06-26 00:47:21 +03:00
button.click()
return QueryPage(self.selenium).wait_for_page_to_load()