class TestTacoTodos(object): def setup_method(self, method): self.driver = WebDriver(desired_capabilities=desired_capabilities, command_executor=command_executor) self.current_method_name = method.__name__ def teardown_method(self, method): self.driver.close() self.driver.quit() def test_todo_counts(self): tacotodos = TacoTodoPage(self.driver).open() tacotodos.new_todo = 'Bean and egg taco \n' tacotodos.new_todo = 'Potato, egg & cheese \n' tacotodos.new_todo = 'Nopales y huevos\n' tacotodos.new_todo = 'Crispy taco\n' tacotodos.new_todo = 'Cruspy taco\n' tacotodos.new_todo = 'Crepes\n' assert 6 == tacotodos.todos_remaining tacotodos.complete_all_todos() assert 6 == tacotodos.todos_completed assert 6 == tacotodos.todos_listed assert 0 == tacotodos.todos_remaining tacotodos.clear_completed_todos() assert 0 == tacotodos.todos_listed assert 0 == tacotodos.todos_completed
class TestFlipkartPage(object): ''' 1. Check that the Flipkart's page is loaded. i.e active internet connection existss 2. ''' def setup_class(self): self.driver = WebDriver() self.welcome_page = FlipkartPage(self.driver).open() def teardown_class(self): self.driver.close() self.driver.quit() def test_flipkart_welcome(self): ''' Check that we have landed on Flipkart's main page. ''' assert 'Flipkart' in self.welcome_page.title def test_search(self): ''' Check the availability of the search bar on the page. If the search bar exists, we search for "laptop". ''' assert self.welcome_page.has_search() self.search_page = self.welcome_page.search('laptop') assert self.search_page.has_sorting_options() self.new_search_page = self.search_page.sort_by_popularity() assert self.new_search_page.has_products() assert self.new_search_page.get_details is not None
def main(): ''' The main script to perform the task.''' # Setting up the driver and loading Flipkart's landing page driver = WebDriver() welcome_page = FlipkartPage(driver).open() # Searching for "laptop" search_page = welcome_page.search('laptop') # Sorting the results by Popularity new_search_page = search_page.sort_by_popularity() # Printing a list of most popular laptops laptops = new_search_page.get_details(max_items=5) for i, laptop in enumerate(laptops): print('--------------------------------------\n') print(i + 1, laptop) print('--------------------------------------\n') # Tearing down the setup driver.close() driver.quit()