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(browser,mydata): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) # Given the DuckDuckGo home page is displayed search_page.load() phrase = mydata[0] print(phrase) # When the user searches for "panda" search_page.search(phrase) getData() # Changes made to main branch. # And the search result query is "panda" assert phrase == result_page.search_input_value() # And the search result links pertain to "panda" #for title in result_page.result_link_titles(): # assert phrase.lower() in title.lower() # Then the search result title contains "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_basic_duckduckgo_search(browser): PHRASE = 'panda' search_page = DuckDuckGoSearchPage(browser) search_page.load() search_page.search(PHRASE) result_page = DuckDuckGoResultPage(browser) assert result_page.link_div_count() > 0 assert result_page.phrase_result_count(PHRASE) > 0 assert result_page.search_input_value() == PHRASE
def test_navigation_to_search_engine(browser): phrase = 'panda' search_page = DuckDuckGoSearchPage(browser) search_page.load() search_page.search(phrase) result_page = DuckDuckGoResultPage(browser) assert result_page.link_div_count() > 0 assert result_page.phrase_result_count(phrase) > 0 assert result_page.search_input_value() == phrase
def test_basic_duckduckgo_search(browser): # Set up test case data PHRASE = 'Tesla' # Search for the phrase search_page = DuckDuckGoSearchPage(browser) search_page.load() search_page.search(PHRASE) # Verify that results appear result_page = DuckDuckGoResultPage(browser) assert result_page.link_div_count() > 0 assert result_page.phrase_result_count(PHRASE) > 0 assert result_page.search_input_value() == PHRASE
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_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_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 test_basic_duckduckgo_search(browser): #, cbt_uploader 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" assert result_page.result_count_for_phrase(PHRASE) > 0
def test_basic_duckduckgo_search(browser): search_page = DuckDuckGoSearchPage(browser) result_page = DuckDuckGoResultPage(browser) #Given DDG home page is displayed search_page.load() search_page.search("panda") #Given the DuckDuckGo home page is displayed assert "panda" in result_page.title() #When the user searches ofr "Panda" assert "panda" == result_page.search_input_value() #Then the search result title contains "Panda" assert result_page.result_count_for_phrase("panda") > 0 assert True
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_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(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_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,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): # URL = 'https://www.duckduckgo.com' # PHRASE = 'panda' # browser.get(URL) # search_input = browser.find_element_by_id('search_form_input_homepage') # search_input.send_keys(PHRASE + Keys.RETURN) # link_divs = browser.find_elements_by_css_selector('#links > div') # assert len(link_divs) > 0 # xpath = f"//div[@id='links']//*[contains(text(), '{PHRASE}')]" # phrase_results = browser.find_elements_by_xpath(xpath) # assert len(phrase_results) > 0 # search_input = browser.find_element_by_id('search_form_input') # assert search_input.get_attribute('value') == PHRASE PHRASE = 'panda' search_page = DuckDuckGoSearchPage(browser) search_page.load() search_page.search(PHRASE) result_page = DuckDuckGoResultPage(browser) assert result_page.link_div_count() > 0 assert result_page.phrase_result_count(PHRASE) > 0 assert result_page.search_input_value() == PHRASE
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")