Adds tests for Get Mozilla Updates widget #163

Merged
merged 13 commits into from Feb 12, 2013

Conversation

Projects
None yet
5 participants
Contributor

casschin commented Jan 22, 2013

Adds tests for the widget into the about tests. Moved form data variables into their respective tests.

casschin added some commits Jan 20, 2013

Adds a slew of new tests
This test needed a bit more coverage to test the various link, images,
and email form at the bottom.

I replaced the existing functions to gather links/images with
explicitly declared elements and locators. I think this is probably a
better approach since we want to test against what we expect to be
there, not what is actually on the page.

I added a function that allows you to select options in a select drop
down menu. since it takes a few lines to accomplish that.

I updated the `get_response_code` function so that it returns a timeout
http response. I noticed that http://getmockery.com/, one of the links
on the page, never loads and was causing the test to get stuck because
it can't handle a timeout.
Adds Get Mozilla Updates widget tests
Note that the `select_option` function is included in this because it's
used to select the country in the form.
tests/test_about.py
+ def test_get_mozilla_updates_links_are_visible(self, mozwebqa):
+ about_page = AboutPage(mozwebqa)
+ about_page.go_to_page()
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_email_input).click()
@teodosia

teodosia Jan 22, 2013

Contributor

All selenium related actions should be done in the page objects, not in the tests.

pages/desktop/base.py
+
+ class GetMozillaUpdates(Page):
+
+ _get_mozilla_updates_email_input = (By.ID, 'id_email')
@AndreiH

AndreiH Jan 22, 2013

Contributor

Here we should have the "_locator" attribute.

tests/test_about.py
+ about_page = AboutPage(mozwebqa)
+ about_page.go_to_page()
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_email_input).click()
+ about_page.wait_for_element_visible(*about_page.GetMozillaUpdates._get_mozilla_updates_privacy_checkbox)
@teodosia

teodosia Jan 22, 2013

Contributor

This wait should also be in the page object.

tests/test_about.py
+ about_page.select_option(country, about_page.GetMozillaUpdates._get_mozilla_updates_country_select)
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_privacy_checkbox).click()
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_submit_button).click()
+ Assert.true(success_url == about_page.url_current_page[:len(success_url)], \
@AndreiH

AndreiH Jan 22, 2013

Contributor

the backslash is redundant between brackets

tests/test_about.py
+ about_page.select_option(country, about_page.GetMozillaUpdates._get_mozilla_updates_country_select)
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_privacy_checkbox).click()
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_submit_button).click()
+ Assert.true(mozillabased_url == about_page.url_current_page[:len(mozillabased_url)], \
@AndreiH

AndreiH Jan 22, 2013

Contributor

Here as well, the backslash is redundant between brackets

tests/test_about.py
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_email_input).send_keys(valid_email)
+ about_page.select_option(country, about_page.GetMozillaUpdates._get_mozilla_updates_country_select)
+ about_page.selenium.find_element(*about_page.GetMozillaUpdates._get_mozilla_updates_submit_button).click()
+ Assert.true(mozillabased_url == about_page.url_current_page[:len(mozillabased_url)], \
@AndreiH

AndreiH Jan 22, 2013

Contributor

Here as well. :)

Contributor

AndreiH commented Jan 22, 2013

Thanks for the pull @casschin.

Contributor

casschin commented Jan 23, 2013

I moved the Selenium actions to page.py, but I'm getting these errors and I'm not sure how to fix it:

TypeError: unbound method trigger_email_form() must be called with GetMozillaUpdates instance as first argument (got nothing instead)

Anyone have any input?

Contributor

teodosia commented Jan 23, 2013

Thank you for the fast update, casschin!
Here is a similar test that checks the same region, but on a different page: https://github.com/mozilla/mcom-tests/blob/master/tests/test_apps.py#L89
You can update this pull by following the same pattern in the test so we have a consistency among our files.
I would suggest moving the locators and methods from your GetMozillaUpdates into about.py using this as a model https://github.com/mozilla/mcom-tests/blob/master/pages/desktop/apps.py#L44

Collaborator

bobsilverberg commented Jan 23, 2013

The Get Mozilla Updates widget is used on many pages, so maybe it makes sense to keep it in base.py, as @casschin has done. Otoh, it isn't on all pages, so I'm torn; moving it to about.py makes sense too. In either case, follow @teodosia's advice to update the pull and let us know if that resolves your errors.

Moves email form tests to about.py and other tweaks
* Changes the names of the locators and tests to be more consistent
with other email tests
* Adds a test to check if the form exists
* Adds a test to check if the form fields exist
Contributor

casschin commented Jan 25, 2013

@teodosia, looks like the email form on the apps page is a little different from the one one the about page based on the form itself and the email I got when I signed up. I'm going to take the code from the apps page and tweak it a bit so it handles issues like link tests. Let me know how it looks.

Also, I think I was getting those errors because I forgot to append self. to the beginning of my locators when using find_element.

tests/test_about.py
+ about_page.select_option(country, about_page._sign_up_form_country_select_locator)
+ about_page.check_privacy_checkbox()
+ about_page.submit_form()
+ Assert.true(success_url == about_page.url_current_page[:len(success_url)],
@bobsilverberg

bobsilverberg Feb 4, 2013

Collaborator

I am getting a failure on this assert:

AssertionError: Expected current URL to be https://donate.mozilla.org/page/st/sign-up-for-mozilla, found https://sendto.mozilla.org/page/s/sign-up-for-mozilla instead.

Perhaps it would make sense to just check that the url contains 'sign-up-for-mozilla' rather than asserting a specific host?

tests/test_about.py
+ invalid_email = 'noreplymozilla.com'
+ country = 'US'
+ about_page.go_to_page()
+ mozillabased_url = about_page.url_current_page
@bobsilverberg

bobsilverberg Feb 4, 2013

Collaborator

I think the name of this variable is a carry over from the other test file. Perhaps a better name would be expected_url.

Collaborator

bobsilverberg commented Feb 4, 2013

Thanks for the pull request @casschin. Other than my last comments it looks very good.

Contributor

AlinT commented Feb 5, 2013

There is reproducible fail: http://pastebin.mozilla.org/2116751

Fix for test fail
* Changed a few test names. I think it makes it sound less awkward
* Changed the success url for some tests to URL slugs
* Updated a URL variable to be more appropriate for the new test
location
Contributor

AndreiH commented Feb 12, 2013

Nice work @casschin, tests look good and they all pass. Thanks for the pull 👍

Contributor

AlinT commented Feb 12, 2013

Looks good to me!

AlinT added a commit that referenced this pull request Feb 12, 2013

Merge pull request #163 from casschin/get-mozilla-updates
Adds tests for Get Mozilla Updates widget

@AlinT AlinT merged commit 5c270e6 into mozilla:master Feb 12, 2013

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