def search_phrase(browser, text):
    search_page = DuckDuckGoSearchPage(browser)

    # search_input = browser.find_element_by_name('q')
    # search_input.send_keys(text + Keys.RETURN)

    search_page.search(text + Keys.RETURN)
Ejemplo n.º 2
0
    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")
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
def test_search(browser):
    PHRASE = 'pytest selenium'
    search_page = DuckDuckGoSearchPage(browser)
    search_page.load()
    # Assert title is correct
    assert (search_page.get_title()[:10] == 'DuckDuckGo')
    search_page.search(PHRASE)
    # Assert title now starts with search phrase (search has been successful)
    assert (search_page.get_title()[:len(PHRASE)] == PHRASE)
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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_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)
Ejemplo n.º 10
0
def test_duckduckgo_news_search(browser):
    search_page = DuckDuckGoSearchPage(browser)
    result_page = DuckDuckGoResultPage(browser)
    PHRASE = "panda"

    search_page.load()
    search_page.search(PHRASE)

    result_page.change_to_news_search()

    links_text = result_page.get_news_links_text()
    matches = [t for t in links_text if PHRASE.lower() in t.lower()]
    assert len(matches) > 0
Ejemplo n.º 11
0
def test_click_first_result(browser, phrase='panda'):

    search_page = DuckDuckGoSearchPage(browser)
    result_page = DuckDuckGoResultPage(browser)

    # Load duckduckgo.com page
    search_page.load()

    # Search for phrase and click first result
    search_page.search(phrase)
    result_page.check_first_result()

    # Check if first result contains logo
    keywords = result_page.search_for_keywords().get_attribute("content").lower()
    assert phrase in keywords
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_duckduckgo_results_click_nth_link(browser):
    search_page = DuckDuckGoSearchPage(browser)
    result_page = DuckDuckGoResultPage(browser)
    external_page = ExternalPage(browser)

    SEARCH_ENGINE_NAME = "DuckDuckGo"
    phrase = "Beatles"
    index = 0

    search_page.load()
    search_page.search(phrase)
    result_page.click_nth_result(index)

    assert phrase in external_page.title(phrase)
    assert SEARCH_ENGINE_NAME not in external_page.title(phrase)
Ejemplo n.º 14
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
Ejemplo n.º 15
0
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()
Ejemplo n.º 16
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
Ejemplo n.º 17
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 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()
Ejemplo n.º 19
0
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)
Ejemplo n.º 20
0
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
Ejemplo n.º 21
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()
Ejemplo n.º 22
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()
Ejemplo n.º 23
0
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):
    # 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
Ejemplo n.º 25
0
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()
Ejemplo n.º 26
0
def test_basic_duckduckgo_search(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)

    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()
Ejemplo n.º 27
0
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")
Ejemplo n.º 28
0
def test_search(browser):
    phrase = 'garmin'

    search_page = DuckDuckGoSearchPage(browser)
    search_page.load()
    search_page.search(phrase)