Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added test for search with data into test_search_results #25

Merged
merged 3 commits into from Sep 15, 2012

Conversation

Projects
None yet
4 participants
Collaborator

rbillings commented Sep 7, 2012

No description provided.

@AlinT AlinT commented on an outdated diff Sep 11, 2012

pages/regions/header.py
@@ -15,6 +15,7 @@ class HeaderRegion(Page):
_media_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(5) a')
_docs_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(6) a')
_search_button_locator = (By.CSS_SELECTOR, '#search button')
+ _search_field_locator = (By.CSS_SELECTOR, '#search')
@AlinT

AlinT Sep 11, 2012

Contributor

This is not the locator for the seach field input. This is one example of the search_field_locator:
(By.CSS_SELECTOR, '#search input#s')

Also because the locator isn't pointing correctly to what it should, the test is failing.

@AlinT AlinT commented on an outdated diff Sep 11, 2012

tests/test_search_results.py
@@ -20,3 +21,15 @@ def test_no_results_returned_from_blank_search(self, mozwebqa):
home_page.header_region.click_search_button()
Assert.true(home_page.is_the_current_page)
Assert.true(home_page.get_url_current_page().endswith('/?s='))
+
+ @pytest.mark.nondestructive
+ def test_search_results_returned(self,mozwebqa):
+ home_page = HomePage(mozwebqa)
+ home_page.go_to_home_page()
+
+ search_results_page = home_page.header_region.type_in_search_field('job board')
+ search_results_page = home_page.header_region.click_search_button()
+
+ expected_text= "Search results"
+ Assert.contains(expected_text, search_results_page._page_title)
+ Assert.true(search_results_page.get_url_current_page().endswith('/?s='))
@AlinT

AlinT Sep 11, 2012

Contributor

Why is this assert here, because the url of the current page after the search does not end with /?s= , it ends with /?s=

@AlinT AlinT commented on an outdated diff Sep 11, 2012

tests/test_search_results.py
@@ -20,3 +21,15 @@ def test_no_results_returned_from_blank_search(self, mozwebqa):
home_page.header_region.click_search_button()
Assert.true(home_page.is_the_current_page)
Assert.true(home_page.get_url_current_page().endswith('/?s='))
+
+ @pytest.mark.nondestructive
+ def test_search_results_returned(self,mozwebqa):
+ home_page = HomePage(mozwebqa)
+ home_page.go_to_home_page()
+
+ search_results_page = home_page.header_region.type_in_search_field('job board')
@AlinT

AlinT Sep 11, 2012

Contributor

You should simply make home_page.header_region.type_in_search('job board'), because this method does not return anything.

Contributor

bebef1987 commented Sep 14, 2012

the test is too fragile...
ex:
If the title is "No Search results found" the test will pass

You could count if there is data returned...
ex:
Do a
Assert.greater_equal(1, len(self.selenium.find_elements(By.CSS_SELECTOR, "#content-main > article")))

Collaborator

rbillings commented Sep 14, 2012

Thanks AlinT & bebef1987 for your suggestions!

Collaborator

stephendonner commented Sep 15, 2012

Merged!

stephendonner added a commit that referenced this pull request Sep 15, 2012

Merge pull request #25 from rbillings/searchresults
Added test for search with data into test_search_results

@stephendonner stephendonner merged commit 9f73c63 into mozilla:master Sep 15, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment