Ejemplo n.º 1
0
class StartPage(BasePage):
    people = WebLabel(By.XPATH, "//*[text()='Люди']")
    news_tip = WebLink(
        By.XPATH,
        "//ul[@class = 'b-main-navigation']//span[contains(text(), 'Новости')]"
    )
    news_tip_active = WebLink(
        By.XPATH,
        "//li[contains(@class, 'b-main-navigation__item_active')]//span[contains(text(), 'Новости')]"
    )
    subsections_headers = WebLabel(
        By.XPATH, "//header[@class='b-main-page-blocks-header-2 cfix']")
    red_tip = WebLabel(
        By.XPATH,
        "//div[contains(normalize-space(@class), 'news-tidings__button_views_popular')]"
    )

    people_tip = WebLink(
        By.XPATH,
        "//div[@class = 'b-main-navigation__dropdown-title']//a[contains(text(), 'Люди')]"
    )
    catalog_tip = WebLink(By.XPATH,
                          "//span[@class = 'b-main-navigation__text']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.people.get_element()

    def is_news_able(self):
        return self.news_tip.is_clickable()

    def are_subsections_have_correct_names(self, bar_items):
        return [
            item.value for item in bar_items
        ] == self.subsections_headers.get_text_from_amount_of_elements()

    def is_news_underlined(self):
        self.helpers.move_to_element(self, self.news_tip)
        return self.news_tip_active.get()

    def is_element_red(self):
        list_of_text = self.red_tip.get_text_from_amount_of_elements()
        list_of_more_30k = [i for i in list_of_text if i > 30000]

        return list_of_text == list_of_more_30k

    def go_to_people_page(self):
        self.helpers.move_to_element(self, self.news_tip)
        # wait for item
        WebDriverWait(self.driver, TimeOutConstants.BUTTON_TIMEOUT).\
            until(expected_conditions.presence_of_element_located((self.people_tip.by, self.people_tip.value)))
        self.people_tip.click()
        return NewsPage(self.driver)

    def go_to_catalog_page(self):
        self.catalog_tip.click()
        return CatalogPage(self.driver)
Ejemplo n.º 2
0
class NewsPage(BasePage):
    active_tab = WebLabel(
        By.XPATH, "//li[contains(@class, 'project-navigation__item_active')]")
    predicted_text_of_label = 'люди'

    first_news_link = WebLink(By.XPATH, "//a[@class = 'news-tidings__stub']")
    first_news = WebLink(By.XPATH, "//a[@class = 'news-tidings__link']//span")
    news_preview_title = WebLabel(By.XPATH,
                                  "//div[@class='news-tidings__subtitle']")
    title = WebLink(By.XPATH, "//div[@class = 'news-header__title']")
    news_elements = WebElementList(
        By.XPATH,
        "//div[@class='news-tidings__item news-tidings__item_1of3 news-tidings__item_condensed']"
    )

    news_title = WebLink(By.XPATH, "//div[@class='news-tidings__subtitle']")
    news_text_preview = WebLink(
        By.XPATH, "//div[contains(@class, 'news-tidings__speech')]")
    news_image = WebLink(By.XPATH, "//div[@class='news-tidings__preview']")
    news_number_of_views = WebLink(By.XPATH,
                                   "//div[@class='news-tidings__group']")
    news_number_of_comments = WebLink(By.XPATH,
                                      "//a[@class='news-tidings__comment']")
    news_publishing_date = WebLink(By.XPATH,
                                   "//div[@class='news-tidings__time']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_bar_selected(self, item):
        text_of_active_tab = self.active_tab.get_text().lower()
        return text_of_active_tab == item.value

    def get_text_of_first_news(self):
        return self.first_news.get_text().lower()

    def is_news_block_tittle_present(self):
        return self.news_title.get_text_from_amount_of_elements()

    def is_news_block_text_preview_present(self):
        return self.news_text_preview.get_text_from_amount_of_elements()

    def is_news_block_image_present(self):
        return self.news_image.get_text_from_amount_of_elements()

    def is_news_block_number_of_views_present(self):
        return self.news_number_of_views.get_text_from_amount_of_elements()

    def is_news_block_number_of_comments_present(self):
        return self.news_number_of_comments.get_text_from_amount_of_elements()

    def is_news_block_publishing_date_present(self):
        return self.news_publishing_date.get_text_from_amount_of_elements()

    def go_to_certain_news_page(self):
        self.first_news_link.click()
        return CertainNewsPage(self.driver)
Ejemplo n.º 3
0
class CatalogComparisonPage(BasePage):
    comparison_column = WebElementList(By.XPATH, "//td[contains(@class, 'product-table__cell')]")
    comparison_column_highlighted = WebLabel(By.XPATH, "//td[contains(normalize-space(@class), 'product-table__cell product-table__cell_accent')]")

    def __init__(self, driver):
        super().__init__(driver)

    def is_the_best_of_first_sections_highlighted(self):
        # get list of class-attribute values and text values OF ALL sells
        list_of_class_values = self.comparison_column.get_attribute('class')
        list_of_text = self.comparison_column.get_text_from_amount_of_elements()

        list_of_4_items_class_values = []
        list_of_4_items_text = []
        is_highlighted = True

        for i in range(len(list_of_class_values)):
            # get four items from lists
            list_of_4_items_class_values.append(list_of_class_values[i])
            list_of_4_items_text.append(list_of_text[i])

            # if lists_of_4_elements contains 4 elements check them for highlighted sells
            if i + 1 % 4 == 0:
                max_el = 0
                position = 0
                for item in range(len(list_of_4_items_text)):
                    number = get_list_of_numbers_from_string(list_of_text[item])
                    if max_el < number:
                        max_el = number
                        position = item

                if "product-table__cell_accent" not in list_of_class_values[position]:
                    is_highlighted = False
        return is_highlighted
Ejemplo n.º 4
0
class InstagramPage(BasePage):
    instagram_header = WebLabel(By.XPATH, "//div[@class = 'nZSzR']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.instagram_header.get_element()
Ejemplo n.º 5
0
class RSSPage(BasePage):
    rss_header = WebLabel(By.XPATH, "//h2[@class='page_name']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.rss_header.get_element()
Ejemplo n.º 6
0
class FacebookPage(BasePage):
    facebook_header = WebLabel(By.XPATH, "//a[@class = '_64-f']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.facebook_header.get_element()
Ejemplo n.º 7
0
class OKPage(BasePage):
    ok_header = WebLabel(By.XPATH, "//h1[@class='mctc_name_tx']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.ok_header.get_element()
Ejemplo n.º 8
0
class CatalogPage(BasePage):
    cart_link = WebLink(By.XPATH,
                        "//a[@class = 'b-top-navigation-cart__link']")
    catalog_bar_tip = WebLink(
        By.XPATH,
        "//span[@class = 'catalog-navigation-classifier__item-title']")
    catalog_subcategories = WebLabel(
        By.XPATH, "//div[@class = 'catalog-navigation-list__category']")
    catalog_subcategories_tip = WebLink(
        By.XPATH,
        "//div[@class = 'catalog-navigation-list__aside-title' and contains(normalize-space(text()), '{}')]"
    )
    first_catalog_subcategories_right_tip = WebLink(
        By.CSS_SELECTOR,
        "//a[@class = 'catalog-navigation-list__dropdown-item']")
    second_catalog_subcategories_right_tip = WebLink(
        By.CSS_SELECTOR,
        "//div[@class = 'catalog-navigation-list__beside'][style = 'display: none;']"
    )
    certain_subcategories_right_tip = WebLink(
        By.XPATH, "//a[@class = 'catalog-navigation-list__dropdown-item']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_concrete_catalog_item_open(self):
        return self.certain_subcategories_right_tip.is_present()

    def go_to_cart_page(self):
        self.cart_link.click()
        return CartPage(self.driver)

    def is_catalog_subtitles_visible(self, bar_items):
        list_of_elements_text = self.catalog_bar_tip.get_text_from_amount_of_elements(
        )
        list_of_bar_items = [bar_item.value for bar_item in bar_items]
        return list_of_elements_text == list_of_bar_items

    def is_catalog_subcategories_visible(self):
        self.helpers.move_to_element(self, self.catalog_bar_tip)
        return self.catalog_subcategories.get_element()

    def is_catalog_subcategories_list_changed(self):
        self.catalog_bar_tip.click()
        if self.first_catalog_subcategories_right_tip.is_present():
            self.catalog_subcategories_tip.click()
        return self.second_catalog_subcategories_right_tip

    def is_navigate_to_concrete_catalog_item(self):
        self.catalog_bar_tip.click()
        self.catalog_subcategories_tip.click()
        return self.is_concrete_catalog_item_open()

    def go_to_certain_catalog_group(self, name_of_tip):
        self.catalog_bar_tip.click()
        self.catalog_subcategories_tip.with_text(name_of_tip).click()
        self.certain_subcategories_right_tip.click()
        return CertainCatalogGroupPage(self.driver)
class CatalogCertainItemPage(BasePage):
    description_of_item = WebLabel(
        By.XPATH, "//div[@class = 'offers-description__specs']")

    def __init__(self, driver):
        super().__init__(driver)

    def get_text_from_description(self):
        return self.description_of_item.get_text()
class ConnectWithRedactionPage(BasePage):
    connect_with_redaction_header = WebLabel(By.XPATH,
                                             "//h2[@class='page_name']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.connect_with_redaction_header.get_element()
Ejemplo n.º 11
0
class YouTubePage(BasePage):
    youtube_header = WebLabel(By.XPATH,
                              "//h1[@class='c4-tabbed-header-title']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.youtube_header.get_element()
Ejemplo n.º 12
0
class CartPage(BasePage):
    empty_cart_text = WebLabel(By.XPATH, "//div[@class = 'cart-message__description']")
    predicted_text = "Ваша корзина пуста"

    def __init__(self, driver):
        super().__init__(driver)

    def is_empty_cart_text_present(self):
        return self.predicted_text in self.empty_cart_text.get_text()
class CertainCatalogGroupPage(BasePage):
    with_delivery_in_bel_tip = WebCheckBox(
        By.XPATH,
        "//span[@class = 'schema-filter__checkbox-text' and text() = 'С доставкой по Беларуси']"
    )
    amount_of_results_tip = WebButton(
        By.XPATH,
        "//div[contains(@class, 'schema-filter-button__state_initial')]")
    title_of_item = WebLink(By.XPATH,
                            "//div[@class = 'schema-product__title']")
    preview_of_item = WebLabel(
        By.XPATH, "//span[@data-bind='html: product.description']")
    choice_check_boxes = WebElementList(
        By.XPATH,
        "//div[@class='schema-product schema-product_narrow-sizes']//span[@class = 'i-checkbox__faux']"
    )
    comparison_tip = WebLink(
        By.XPATH,
        "//a[@class = 'compare-button__sub compare-button__sub_main']")
    cheap_order_tip = WebButton(By.XPATH,
                                "//div[@class = 'schema-order__item']")
    list_of_prices = WebElementList(
        By.XPATH, "//div[@class = 'schema-product__price']//span")
    order_tip = WebButton(By.XPATH, "//a[@class = 'schema-order__link']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_filter_response(self):
        return self.with_delivery_in_bel_tip.click(
        ) and self.amount_of_results_tip.click()

    def get_text_of_preview(self):
        return self.preview_of_item.get_text()

    def go_to_certain_catalog_group(self):
        self.title_of_item.click()
        return CatalogCertainItemPage(self.driver)

    def is_list_of_items_filtered_cheap_first(self):
        self.order_tip.click()
        self.cheap_order_tip.click()
        list_of_prices = self.list_of_prices.get_text_from_amount_of_elements()
        # get list of numbers from list of strings
        list_of_numbers = []
        for i in list_of_prices:
            list_of_numbers.append(get_list_of_numbers_from_string(i)[0])

        is_list_sorted = True
        for i in range(len(list_of_numbers) - 1):
            if list_of_numbers[i] > list_of_numbers[i + 1]:
                is_list_sorted = False
                break
        return is_list_sorted

    def is_first_in_column_items_checked(self, number_of_checked_items=3):
        list_of_checked = []

        list_of_elements = self.choice_check_boxes.get_elements()
        counter = number_of_checked_items
        for i in list_of_elements:
            list_of_checked.append(i.click())
            counter -= 1
            if counter == 0:
                break
        return len(list_of_checked) == number_of_checked_items

    def go_to_comparison_page(self):
        self.is_first_in_column_items_checked()
        self.comparison_tip.click()
        return CatalogComparisonPage(self.driver)
Ejemplo n.º 14
0
class CertainNewsPage(BasePage):
    comments_section = WebLink(By.XPATH, "//div[@id= 'comments']")
    more_comments_button = WebButton(
        By.XPATH,
        "//div[@class= 'news-form__control news-form__control_condensed']")
    amount_of_comments = WebLabel(
        By.XPATH, "//div[@class= 'news-form__title news-form__title_middle']")
    news_title = WebLabel(By.XPATH, "//div[@class='news-header__title']")
    discussion_tittle = WebLabel(
        By.XPATH,
        "//div[@class='news-comment__title news-comment__title_secondary']")
    arrow_button_up = WebButton(
        By.XPATH, "//span[contains(@class, 'js-scrolling-button-up')]")
    arrow_button_down = WebButton(
        By.XPATH, "//span[contains(@class, 'js-scrolling-button-down')]")
    onliner_social_profile_tip = WebButton(
        By.XPATH,
        "//a[@class='project-navigation__link project-navigation__link_secondary']"
    )

    youtube_onliner_profile = WebLink(By.XPATH, "//a[@title='Youtube']")
    instagram_onliner_profile = WebLink(By.XPATH, "//a[@title='Instagram']")
    twitter_onliner_profile = WebLink(By.XPATH, "//a[@title='Twitter']")
    ok_onliner_profile = WebLink(By.XPATH, "//a[@title='OK']")
    facebook_onliner_profile = WebLink(By.XPATH, "//a[@title='Facebook']")
    vk_onliner_profile = WebLink(By.XPATH, "//a[@title='VK']")
    connect_to_redaction_onliner_profile = WebLink(
        By.XPATH, "//a[@title='Связаться с редакцией']")
    rss_onliner_profile = WebLink(By.XPATH, "//a[@title='RSS']")

    def __init__(self, driver):
        super().__init__(driver)

    def is_open(self):
        return self.news_title.get_element()

    def is_comments_present(self):
        return self.comments_section.get_element()

    def is_amount_of_comments_more_then_100(self):
        try:
            self.more_comments_button.click()
        except NoSuchElementException:
            return False
        finally:
            number_list = get_list_of_numbers_from_string(
                self.amount_of_comments.get_text())
            number = int(number_list[0])
            return number > 100

    def is_expand_the_list_of_comments(self):
        try:
            self.more_comments_button.click()
            return True
        except NoSuchElementException:
            return None

    def get_text_of_tittle(self):
        return self.news_title.get_text().lower()

    def is_arrows_navigate_to_the_start_of_page(self):
        if self.helpers.move_to_element(self, self.discussion_tittle):
            return self.arrow_button_up.is_clickable()

    def is_arrows_navigate_to_the_end_of_page(self):
        if self.helpers.move_to_element(self, self.discussion_tittle):
            return self.arrow_button_down.is_clickable()

    def go_to_youtube_onliner_profile(self):
        self.youtube_onliner_profile.click()
        return YouTubePage(self.driver)

    def go_to_instagram_onliner_profile(self):
        self.instagram_onliner_profile.click()
        return InstagramPage(self.driver)

    def go_to_twitter_onliner_profile(self):
        self.twitter_onliner_profile.click()
        return TwitterPage(self.driver)

    def go_to_ok_onliner_profile(self):
        self.ok_onliner_profile.click()
        return OKPage(self.driver)

    def go_to_facebook_onliner_profile(self):
        self.facebook_onliner_profile.click()
        return FacebookPage(self.driver)

    def go_to_vk_onliner_profile(self):
        self.vk_onliner_profile.click()
        return VKPage(self.driver)

    def go_to_connect_to_redaction_onliner_profile(self):
        self.connect_to_redaction_onliner_profile.click()
        return ConnectWithRedactionPage(self.driver)

    def go_to_rss_onliner_profile(self):
        self.rss_onliner_profile.click()
        return RSSPage(self.driver)