Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Created new test for searching with no data #24

Merged
merged 5 commits into from

5 participants

@rbillings
Owner

No data is entered, search is clicked, no results are returned, user remains on the home page.

pages/search_results.py
((6 lines not shown))
+
+from selenium.webdriver.common.by import By
+
+from base import BasePage
+
+
+class SearchResultsPage(BasePage):
+
+ _page_title = u'Search results'
+ #_search_page_header_locator = (By.ID, 'section-title')
+
+ def go_to_docs_page(self):
+ self.selenium.get(self.testsetup.base_url + '/?s')
+ self.is_the_current_page
+
+ # @property
@stephendonner Owner

Did you mean to comment this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pages/regions/header.py
@@ -34,3 +36,12 @@ def click_docs_link(self):
self.selenium.find_element(*self._docs_link_locator).click()
from pages.docs import DocsPage
return DocsPage(self.testsetup)
+
+ def click_search_field(self):
@stephendonner Owner

I might just be missing it, but do you ever call this method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pages/regions/header.py
@@ -14,7 +14,9 @@ class HeaderRegion(Page):
_events_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(4) a')
_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_field_locator = (By.CSS_SELECTOR, '#search input#s' )
+ _search_button_locator = (By.CSS_SELECTOR, '#search fieldset input#s')
+
@teodosia Collaborator

PEP8 issue: header.py:19:1: W293 blank line contains whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pages/search_results.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from selenium.webdriver.common.by import By
+
+from base import BasePage
+
+
+class SearchResultsPage(BasePage):
+
@teodosia Collaborator

search_results.py:13:1: W293 blank line contains whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pages/search_results.py
((1 lines not shown))
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from selenium.webdriver.common.by import By
+
+from base import BasePage
+
+
+class SearchResultsPage(BasePage):
+
+ _page_title = u'Search results'
+
+
@teodosia Collaborator

search_results.py:17:5: E303 too many blank lines (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
page.py
@@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from selenium.webdriver.support.ui import WebDriverWait
+from selenium.common.exceptions import NoSuchElementException
@AlinT
AlinT added a note

unused import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pages/regions/header.py
@@ -14,7 +14,9 @@ class HeaderRegion(Page):
_events_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(4) a')
_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_field_locator = (By.CSS_SELECTOR, '#search input#s' )
@AlinT
AlinT added a note

there is an extra whitespace before )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pages/regions/header.py
@@ -14,7 +14,9 @@ class HeaderRegion(Page):
_events_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(4) a')
_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_field_locator = (By.CSS_SELECTOR, '#search input#s' )
+ _search_button_locator = (By.CSS_SELECTOR, '#search fieldset input#s')
@AlinT
AlinT added a note

_search_field_locator & _search_button_locator point to the same element, when instead _search_button_locator should point to the search button, an example of this locator would be:
_search_button_locator = (By.CSS_SELECTOR, '#search button')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tests/test_search_results.py
((7 lines not shown))
+import pytest
+from unittestzero import Assert
+
+from pages.home import HomePage
+from pages.search_results import SearchResultsPage
+
+
+class TestSearchPage:
+
+ @pytest.mark.nondestructive
+ def test_no_results_returned_from_blank_search(self, mozwebqa):
+ home_page = HomePage(mozwebqa)
+ home_page.go_to_home_page()
+
+ search_results_page = home_page.header_region.click_search_button()
+ Assert.true(home_page.is_the_current_page)
@AlinT
AlinT added a note

This test is returning a False positive.
Please make the appropriate changes, so this would become a valid test.
Why did you check that the home_page.is_the_current_page?when you should verify that search_results_page.is_the_current_page?!

@AlinT
AlinT added a note

As an extra check you could do something like:
Assert.true(search_results_page.get_url_current_page().endswith('/?s='))
Also you'll need to implement the get_url_current_page() method in page.py.

@rbillings Owner

AlinT: QMO actually remains on the same page if you click the search button without data, so it is not a false positive. The rest of your suggestions I will happily use in the next test- which verifies searching with data!

@AlinT
AlinT added a note

Also do we not check that the url has changed and ends with '/?s=' ?

@rbillings Owner

AlinT: the url does not change, and does not end with '/?s=' unless there is search data.

@stephendonner Owner

@rbillings odd, it does here:

@rbillings Owner

Well isn't that interesting- in Chrome it does NOT, and in Firefox & Safari it DOES. Now I'm not sure what is the best verification.

@stephendonner Owner

Easy -- the browser we'll be running it in and care about most -- Firefox :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tests/test_search_results.py
((6 lines not shown))
+
+import pytest
+from unittestzero import Assert
+
+from pages.home import HomePage
+from pages.search_results import SearchResultsPage
+
+
+class TestSearchPage:
+
+ @pytest.mark.nondestructive
+ def test_no_results_returned_from_blank_search(self, mozwebqa):
+ home_page = HomePage(mozwebqa)
+ home_page.go_to_home_page()
+
+ search_results_page = home_page.header_region.click_search_button()
@AlinT
AlinT added a note

what's the point in attributing the object to a new variable(search_results_page) if this is not being used anywhere in the test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
tests/test_search_results.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import pytest
+from unittestzero import Assert
+
+from pages.home import HomePage
+from pages.search_results import SearchResultsPage
@AlinT
AlinT added a note

This import is not being used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@m8ttyB m8ttyB commented on the diff
tests/test_search_results.py
((5 lines not shown))
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import pytest
+from unittestzero import Assert
+
+from pages.home import HomePage
+
+
+class TestSearchPage:
+
+ @pytest.mark.nondestructive
+ def test_no_results_returned_from_blank_search(self, mozwebqa):
+ home_page = HomePage(mozwebqa)
+ home_page.go_to_home_page()
+
+ home_page.header_region.click_search_button()
@m8ttyB Owner
m8ttyB added a note

awesome .. thanks!

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

Tasty spicy food -- lgtm and runs like an ostrich gobbling down a hot pepper.

@m8ttyB m8ttyB merged commit cf5fc80 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  page.py
@@ -29,3 +29,6 @@ def is_element_visible(self, locator):
return self.selenium.find_element(*locator).is_displayed()
except:
return False
+
+ def get_url_current_page(self):
+ return self.selenium.current_url
View
6 pages/regions/header.py
@@ -14,6 +14,7 @@ class HeaderRegion(Page):
_events_link_locator = (By.CSS_SELECTOR, '#nav-main li:nth-child(4) a')
_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')
def click_community_link(self):
self.selenium.find_element(*self._community_link_locator).click()
@@ -34,3 +35,8 @@ def click_docs_link(self):
self.selenium.find_element(*self._docs_link_locator).click()
from pages.docs import DocsPage
return DocsPage(self.testsetup)
+
+ def click_search_button(self):
+ self.selenium.find_element(*self._search_button_locator).click()
+ from pages.search_results import SearchResultsPage
+ return SearchResultsPage(self.testsetup)
View
22 pages/search_results.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from selenium.webdriver.common.by import By
+
+from base import BasePage
+
+
+class SearchResultsPage(BasePage):
+
+ _page_title = u'Search results'
+
+ def go_to_docs_page(self):
+ self.selenium.get(self.testsetup.base_url + '/?s')
+ self.is_the_current_page
+
+ @property
+ def is_page_title_correct(self):
+ return self.selenium.get_title() == self._page_title
View
22 tests/test_search_results.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import pytest
+from unittestzero import Assert
+
+from pages.home import HomePage
+
+
+class TestSearchPage:
+
+ @pytest.mark.nondestructive
+ def test_no_results_returned_from_blank_search(self, mozwebqa):
+ home_page = HomePage(mozwebqa)
+ home_page.go_to_home_page()
+
+ home_page.header_region.click_search_button()
@m8ttyB Owner
m8ttyB added a note

awesome .. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ Assert.true(home_page.is_the_current_page)
+ Assert.true(home_page.get_url_current_page().endswith('/?s='))
Something went wrong with that request. Please try again.