def test_duckduckgo_results_more_results(browser): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) phrase = "Golden retriever" search_page.load() search_page.search(phrase) first_set_of_links = result_page.result_link_titles() result_page.click_more_results() second_set_of_links = result_page.result_link_titles() assert len(second_set_of_links) > len(first_set_of_links)
def test_duckduckgo_expand_results(browser): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) PHRASE = "panda" search_page.load() search_page.search_manual(PHRASE) count_before_more = result_page.result_link_titles() result_page.click_more_results() count_after_more = result_page.result_link_titles() assert len(count_before_more) < len(count_after_more)
def test_basic_duckduckgo_search(browser): # initialize page object and phrase to search search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) PHRASE = "panda" # given duckduckgo homepage search_page.load() # when user searches for "panda" search_page.search(PHRASE) # then the search result query is "panda" assert PHRASE == result_page.search_input_value() # and the search result links pertain to "panda" titles = result_page.result_link_titles() matches = [] for t in titles: if PHRASE.lower() in t.lower(): matches.append(t) assert len(matches) > 0 # return true when there is title in the matches # And search result title contain "panda" assert PHRASE in result_page.title()
def test_basic_duckduckgo_search(self, phrase): self.LOGGER.info("Inside Test") search_page = DuckDuckGoSearchPage(self.driver) result_page = DuckDuckGoResultPage(self.driver) # phrase = "panda" # Given the DuckDuckGo home page is displayed search_page.load() # assert if the page loaded successfully assert search_page.is_loaded() is True # When the user searches the title search_page.search(phrase) # And the search result query is "phrase" assert phrase in result_page.search_input_value() # And the search result links pertain to "phrase" titles = result_page.result_link_titles() matches = [t for t in titles if phrase.lower() in t.lower()] print(matches) assert len(matches) > 0 # Then the search result title contains "phrase" assert phrase in result_page.title() self.LOGGER.info("Finishing Test")
def test_more_results(browser, phrase='panda'): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) # Load duckduckgo.com page search_page.load() # Search for phrase search_page.search(phrase) # Create table of search result links results_before = result_page.result_link_titles() # Expand more results and create new table of search result links result_page.expand_more_results() results_after = result_page.result_link_titles() # Check if new table of links has more elements than previous one assert len(results_after) > len(results_before)
def test_basic_duckduckgo_search(browser, phrase): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) search_page.load() search_page.search(phrase) assert phrase == result_page.search_input_value() titles = result_page.result_link_titles() matches = [title for title in titles if phrase.lower() in title.lower()] assert len(matches) > 0 assert phrase in result_page.title()
def test_check_autosuggestion(browser, phrase='panda'): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) # Load duckduckgo.com page search_page.load() # Write phrase in search textbox search_page.write_search_phrase(phrase) # Search by clicking on first autosuggestion and return its text as_first = search_page.search_by_autosuggestion() # Check if results pertain to clicked autosuggestion titles = result_page.result_link_titles() matches = [t for t in titles if as_first.lower() in t.lower()] assert len(matches) > 0
def test_search_another_phrase(browser, phrase='panda', phrase_new='python'): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) # Load duckduckgo.com page search_page.load() # Write phrase in search textbox and search search_page.search(phrase) # Write phrase in search textbox and search again result_page.search_another_result(phrase_new) # Check if results do not match to previous search phrase titles = result_page.result_link_titles() matches = [t for t in titles if phrase.lower() in t.lower()] assert len(matches) == 0
def test_basic_duckduckgo_search(browser, phrase): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) # Given the DuckDuckGo home page is displayed search_page.load() # When the user searches for the phrase search_page.search(phrase) # Then the search result query is the phrase assert phrase == result_page.search_input_value() # And the search result title contains the phrase assert phrase.lower() in result_page.title() # And the search result links pertain to the phrase for title in result_page.result_link_titles(): assert phrase.lower() in title.lower()
def test_basic_duckduckgo_search(browser): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) PHRASE = "panda" # Given the DuckDuckGo home page is displayed search_page.load() # When the user searches for "panda" search_page.search(PHRASE) # And the search result links pertain to "panda" titles = result_page.result_link_titles() matches = [t for t in titles if PHRASE.lower() in t.lower()] assert len(matches) > 0 # And the search result title contains "panda" # (Putting this assertion last guarantees that the page title will be ready) assert PHRASE in result_page.title()
def test_duckduckgo_selecting_autocomplete_sugestion(browser): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) PHRASE = "panda" search_page.load() search_page.search_by_letter(PHRASE) items = search_page.get_autocomplete_items() NEW_PHRASE = search_page.select_random_option(items) assert NEW_PHRASE in result_page.title() assert NEW_PHRASE == result_page.search_input_value() titles = result_page.result_link_titles() matches = [t for t in titles if NEW_PHRASE.lower() in t.lower()] assert len(matches) > 0
def search_results(browser, phrase): result_page = DuckDuckGoResultPage(browser) # Check search result list # (A more comprehensive test would check results for matching phrases) # (Check the list before the search phrase for correct implicit waiting) # links_div = browser.find_element_by_id('links') # assert len(links_div.find_elements_by_xpath('//div')) > 0 titles = result_page.result_link_titles() matches = [t for t in titles if phrase.lower() in t.lower()] assert len(matches) > 0 # Check search phrase # And the search result query is "phrase" # search_input = browser.find_element_by_name('q') # assert search_input.get_attribute('value') == phrase assert phrase == result_page.search_input_value()
def test_basic_duckduckgo_searh(browser, phrase): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) PHRASE = "panda" #Given the DuckDuckGo home page is displayed search_page.load() #When the user searches for "panda" search_page.search(PHRASE) #Then the search result title contains "panda" assert PHRASE in result_page.title() #And the search result query is "panda" assert PHRASE == result_page.search_input_value() # And the search result links pertain to "panda" titles = result_page.result_link_titles() matches = [t for t in titles if PHRASE.lower() in t.lower()] assert len(matches) > 0
def test_basic_search(browser, phrase): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) #load page search_page.load() #enter search phrase search_page.search(phrase) #make sure phrase in results page results assert phrase == result_page.search_input_values() #make sure phrase is in result links titles = result_page.result_link_titles() matches = [t for t in titles if phrase.lower() in t.lower()] #make suer there is at least one match assert len(matches) > 0 #make sure phrase is in results page title assert phrase in result_page.title()
def test_basic_duckduckgo_search(browser, phrase): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) # Given the DuckDuckGo home page is displayed search_page.load() # When the user searches for "panda" search_page.search(phrase) # Then the search result query is "panda" assert phrase == result_page.search_input_value() # And the search result links pertain to "panda" titles = result_page.result_link_titles() matches = [t for t in titles if phrase.lower() in t.lower()] assert len(matches) > 0 # And the search result title contains "panda" # Putting this assertion last to guarantee that the page title will be ready assert phrase in result_page.title()
def test_basic_duckduckgo_search_using_ENTER(browser, phrase): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) # Given the DuckDuckGo home page is displayed search_page.load() # When the user searches for "panda" search_page.search_using_ENTER(phrase) WebDriverWait(browser, 20).until(EC.title_contains(phrase)) # Then the search result title contains "panda" assert phrase in result_page.get_title() # And the search result links pertain to "panda" for title in result_page.result_link_titles(): if title == "Music and Podcasts, Free and On-Demand | Pandora": continue assert phrase.lower() in title.lower() # And the search result query is "panda" assert phrase == result_page.search_input_value()
def test_basic_duckduckgo_search(browser, phrase1, phrase2): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) phrase = phrase1 + phrase2 # Given the DuckDuckGo home page is displayed search_page.load() # When the user searches for "panda" search_page.search(phrase) # Then the search result title contains "panda" assert phrase in result_page.title() # And the search result query is "panda" assert phrase == result_page.search_input_value() # And the search result links pertain to "panda" titles = result_page.result_link_titles() matches = [t for t in titles if phrase.lower() in t.lower()] assert len(matches) > 0 result_page.print_info()
def test_basic_duckduckgo_search(browser,phrase): searchPage = DuckDuckGoSearchPage(browser) serachResultPage = DuckDuckGoResultPage(browser) # Given the DuckDuckGo home page is displayed searchPage.load() # When the user searches for "panda" searchPage.search(phrase) # Then the search result is "panda" assert phrase == serachResultPage.search_input_value() browser.get_screenshot_as_png() # And the search result links pertain to "panda" for title in serachResultPage.result_link_titles(): assert phrase.lower() in title.lower() # And the search result title contains "panda" assert phrase in serachResultPage.title()
def test_basic_duckduckgo_search(browser): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) PHRASE = "panda" # Given the DuckDuckGo home page is displayed search_page.load() # When the user searches for "panda" search_page.search(PHRASE) # Then the search result title contains "panda" assert PHRASE in result_page.title() # And the search result query is "panda" assert PHRASE == result_page.search_input_value() # And the search result links pertain to "panda" titles = result_page.result_link_titles() matches = [t for t in titles if PHRASE.lower() in t.lower()] assert len(matches) > 0 # TODO: Remove this exception once the test is complete raise Exception("Incomplete Test")