예제 #1
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()
예제 #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")
예제 #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()
예제 #4
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
예제 #5
0
def test_duckduckgo_autocomplete_suggestions(browser):
    search_page = DuckDuckGoSearchPage(browser)
    PHRASE = "panda"

    search_page.load()
    search_page.search_by_letter(PHRASE)

    texts = search_page.get_autocomplete_items_text()
    assert PHRASE in texts
예제 #6
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)
예제 #7
0
def test_duckduckgo_search_manual(browser):
    search_page = DuckDuckGoSearchPage(browser)
    result_page = DuckDuckGoResultPage(browser)
    PHRASE = "panda"

    search_page.load()

    search_page.search_manual(PHRASE)

    assert PHRASE in result_page.title()
def test_click_search_button_leads_to_results(browser):
    search_page = DuckDuckGoSearchPage(browser)
    result_page = DuckDuckGoResultPage(browser)
    phrase = "Antarctica"

    search_page.load()

    search_page.search_and_click_button(phrase)

    assert phrase in result_page.title()
예제 #9
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
예제 #10
0
def test_duckduckgo_click_result(browser):
    search_page = DuckDuckGoSearchPage(browser)
    result_page = DuckDuckGoResultPage(browser)
    result_link_page = DuckDuckGoResultLinkPage(browser)
    PHRASE = "panda"

    search_page.load()
    search_page.search_manual(PHRASE)

    title = result_page.click_result_random()

    assert title in result_link_page.title()
예제 #11
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_autocomplete_suggestions(browser):
    search_page = DuckDuckGoSearchPage(browser)

    phrase = "Vincent"
    phrase_to_find = "Vincent Van Gogh"

    search_page.load()

    search_page.input_phrase(phrase)
    autocomplete_suggestions = search_page.check_autocomplete_suggestions()
    assert phrase_to_find.lower() in list(
        map(lambda x: x.lower(), autocomplete_suggestions))
예제 #13
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
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)
예제 #15
0
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)
예제 #16
0
def test_verify_autosuggestion(browser, phrase='panda'):

    search_page = DuckDuckGoSearchPage(browser)

    # Load duckduckgo.com page
    search_page.load()

    # Write phrase in search textbox
    search_page.write_search_phrase(phrase)

    as_table = search_page.autosuggestion_table()
    matches = [match for match in as_table if match in match]

    assert len(matches) == len(as_table)
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)
예제 #19
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
예제 #20
0
def test_click_on_first_searh_result(browser, phrase):
    search_page = DuckDuckGoSearchPage(browser)
    result_page = DuckDuckGoResultPage(browser)
    detail_page = DuckDuckGoDetailPage(browser)
    # Given the DuckDuckGo home page is displayed
    search_page.load()

    # When the user searches for "panda"
    search_page.search_using_ENTER(phrase)

    # And user click on first search result
    result_page.click_on_first_link()

    #Wait till title is displayed
    WebDriverWait(browser, 20).until(EC.title_contains(phrase))

    # Then user shoud verify new page title
    assert phrase in detail_page.get_detail_page_title()
예제 #21
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
예제 #22
0
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
예제 #23
0
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
예제 #24
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()
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()
예제 #26
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
예제 #27
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
예제 #28
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)
예제 #29
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
예제 #30
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()