class HomePageTest(BrowserTestCase):
    def test_homepage_loaded(self):
        """ Asserts the home page title is correct
        """
        self.home_page = HomePage(self.driver, self.url)
        self.assertIn(TestData.HOME_TITLE_ATM, self.home_page.driver.title)

    def test_homepage_search_toggle(self):
        """Asserts the search toggle is present on home page
        """
        self.home_page = HomePage(self.driver, self.url)
        self.assertTrue(self.home_page.is_enabled(
            Locators.SEARCH_TOGGLE))

    def test_homepage_top_cards(self):
        """ Asserts both air forecasts cards are loaded
        """
        self.home_page = HomePage(self.driver, self.url)
        cards_list = self.home_page.get_elements(Locators.HOME_CARD)
        first_two_cards = [card.text for card in cards_list[:2]]
        self.assertEqual(first_two_cards, TestData.TOP_CARDS_ATM)

    def test_homepage_top_menu_data_link(self):
        """ Checks for the Data link in the header
        """
        self.home_page = HomePage(self.driver, self.url)
        self.home_page.is_enabled(Locators.DATA_LINK)
Esempio n. 2
0
class SearchTest(BrowserTestCase):
    def test_search_by_text(self):
        """ Clicks the search toggle, perform search, asserts counter works
        """
        self.home_page = HomePage(self.driver, self.url)
        self.search_toggle = self.home_page.is_enabled(Locators.SEARCH_TOGGLE)
        self.search_toggle.click()
        self.search_input = self.home_page.is_enabled(Locators.SEARCH_INPUT)
        self.search_input.clear()
        # enter search keyword and submit
        self.search_input.send_keys(TestData.SEARCH_TEXT_ATM)
        self.search_input.submit()
        # get the list of elements displayed after the search
        results = self.home_page.get_elements(Locators.SEARCH_RESULTS)
        self.header = self.home_page.is_enabled(Locators.SEARCH_RESULTS_HEADER)
        first_page_results_count = int(self.header.text.split()[3])
        self.assertEqual(len(results), first_page_results_count)