Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master', remote-tracking branch 'mozilla-mcom-tests/mas…
Browse files Browse the repository at this point in the history
…ter'
  • Loading branch information
retornam committed Sep 22, 2011
2 parents 93054ff + 61966eb commit 44b18d8
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
*.py[co]
rmpyc.sh
/debug/**

37 changes: 26 additions & 11 deletions README.md
Expand Up @@ -3,7 +3,7 @@ Mozilla.com Selenium Tests

This repository holds automated tests for [http://www.mozilla.com][MOZ]

[MOZ]: http://www.mozilla.com
[MOZ]: http://www.mozilla.org

Running Tests
-------------
Expand All @@ -16,25 +16,40 @@ You will need a version of the [Java Runtime Environment][JRE] installed
### Python
Before you will be able to run these tests you will need to have Python 2.6 installed.

Run
__note__

easy_install pip
The below instructions will install the required Python libraries into your
global Python installation. If you work on multiple Python projects that might
end up needing different versions of the same libraries, you might want to
follow `sudo easy_install pip` with `sudo pip install virtualenv`, and then
create and activate a [virtualenv](http://www.virtualenv.org) (e.g. `virtualenv
mcom-tests-env; source mcom-tests-env/bin/activate`) to create a clean
"virtual environment" for just this project. Then you can
`pip install -r requiremenst/requirements.txt` in your virtual environment
without needing to use `sudo`.

If you don't mind installing globally, just run

sudo easy_install pip

followed by

sudo pip install pytest
sudo pip install pytest-xdist
sudo pip install selenium
sudo pip install unittestzero

sudo pip install -r requirements/requirements.txt

__note__

If you are running on Ubuntu/Debian you will need to first do

sudo apt-get install python-setuptools

to install the required Python libraries.

### Selenium
Once this is all set up you will need to download and start a Selenium server. You can download the latest Selenium server from [here][Selenium Downloads]. The filename will be something like 'selenium-server-standalone-2.0b1.jar'
Once this is all set up you will need to download and start a Selenium server. You can download the latest Selenium server from [here][Selenium Downloads]. The filename will be something like 'selenium-server-standalone-x.x.jar (where x.x is current shipping version)'

To start the Selenium server run the following command:

java -jar ~/Downloads/selenium-server-standalone-2.0b1.jar
java -jar ~/Downloads/selenium-server-standalone-x.x.jar (where x.x is current shipping version)

Change the path/name to the downloaded Selenium server file.

Expand All @@ -45,7 +60,7 @@ Change the path/name to the downloaded Selenium server file.
Once the above prerequisites have been met you can run the tests using the
following command:

py.test --browser='*firefox' --site=http://www-trunk.stage.mozilla.com --timeout="120000"
py.test --api=rc --baseurl=http://www.mozilla.org --browser=*firefox

Writing Tests
-------------
Expand Down
2 changes: 1 addition & 1 deletion mozilla_base_page.py
Expand Up @@ -83,7 +83,7 @@ class MozillaBasePage(Page):
_footer_tour_locator,
_footer_future_locator]

_footer_twitter_locator ="css=#footer-twitter a"
_footer_twitter_locator = "css=#footer-twitter a"
_footer_facebbook_locator = "css=#sub-footer-newsletter a"
_footer_moreways_locator = "css=#footer-connect a"
_footer_monthly_newsletter_locator = "css=#sub-footer-newsletter a"
Expand Down
10 changes: 5 additions & 5 deletions page.py
Expand Up @@ -77,7 +77,7 @@ def get_text(self, locator):
return self.selenium.get_text(locator)

def click_link(self, link, wait_flag=False):
self.selenium.click("link=%s" %(link))
self.selenium.click("link=%s" % (link))
if(wait_flag):
self.selenium.wait_for_page_to_load(self.timeout)

Expand Down Expand Up @@ -115,7 +115,7 @@ def wait_for_element_present(self, element):
while not self.is_element_present(element):
time.sleep(1)
count += 1
if count == self.timeout/1000:
if count == self.timeout / 1000:
self.record_error()
raise Exception(element + ' has not loaded')

Expand All @@ -125,7 +125,7 @@ def wait_for_element_visible(self, element):
while not self.is_element_visible(element):
time.sleep(1)
count += 1
if count == self.timeout/1000:
if count == self.timeout / 1000:
self.record_error()
raise Exception(element + " is not visible")

Expand All @@ -134,7 +134,7 @@ def wait_for_element_not_visible(self, element):
while self.is_element_visible(element):
time.sleep(1)
count += 1
if count == self.timeout/1000:
if count == self.timeout / 1000:
self.record_error()
raise Exception(element + " is still visible")

Expand All @@ -143,7 +143,7 @@ def wait_for_page(self, url_regex):
while (re.search(url_regex, self.selenium.get_location(), re.IGNORECASE)) is None:
time.sleep(1)
count += 1
if count == self.timeout/1000:
if count == self.timeout / 1000:
self.record_error()
raise Exception("Sites Page has not loaded")

Expand Down
6 changes: 3 additions & 3 deletions requirements/requirements.txt
@@ -1,9 +1,9 @@
## These are the required python libraries needed to run Selenium tests
## on Mozilla WebQA projects

selenium
pytest
pytest-xdist
BeautifulSoup==3.2.0
unittestzero
pytest-mozwebqa
selenium
unittestzero
BeautifulSoup==3.2.0
10 changes: 5 additions & 5 deletions test_404.py
Expand Up @@ -16,7 +16,7 @@
#
# The Initial Developer of the Original Code is
# Mozilla.
# Portions created by the Initial Developer are Copyright (C) 2010
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s): Raymond Etornam Agbeame
Expand All @@ -42,14 +42,14 @@
@pytest.mark.skip_selenium
class TestStatus(object):

def test_status_code_returns_404(self, testsetup):
url = testsetup.base_url +'/abck'
def test_status_code_returns_404(self, mozwebqa):
url = mozwebqa.base_url + '/abck'
response = urllib.urlopen(url)
Assert.equal(response.code, 404)

def test_xrobots_tag_is_present(self, testsetup):
def test_xrobots_tag_is_present(self, mozwebqa):
'''Test for X-Robots-Tag header'''
url = testsetup.base_url
url = mozwebqa.base_url
response = urllib.urlopen(url)
Assert.contains("X-Robots-Tag", response.info())
Assert.contains('noodp', response.headers.dict.values())
12 changes: 6 additions & 6 deletions test_about.py
Expand Up @@ -43,9 +43,9 @@

class TestAbout:

def test_about_images(self, testsetup):
self.selenium = testsetup.selenium
about_pg = AboutPage(testsetup)
def test_about_images(self, mozwebqa):
self.selenium = mozwebqa.selenium
about_pg = AboutPage(mozwebqa)
about_pg.open("/en-US/about/")
Assert.true(about_pg.participate_image)
Assert.true(about_pg.communications_image)
Expand All @@ -56,9 +56,9 @@ def test_about_images(self, testsetup):
Assert.true(about_pg.store_image)
Assert.true(about_pg.blog_image)

def test_about_text(self, testsetup):
self.selenium = testsetup.selenium
about_pg = AboutPage(testsetup)
def test_about_text(self, mozwebqa):
self.selenium = mozwebqa.selenium
about_pg = AboutPage(mozwebqa)
about_pg.open("/en-US/about/")
Assert.true(about_pg.participate_text)
Assert.true(about_pg.communications_text)
Expand Down
16 changes: 8 additions & 8 deletions test_common.py
Expand Up @@ -42,9 +42,9 @@

class TestCommon:

def test_header_and_footer_links(self, testsetup, url="/firefox/fx/"):
self.selenium = testsetup.selenium
home_pg = MozillaBasePage(testsetup)
def test_header_and_footer_links(self, mozwebqa, url="/firefox/fx/"):
self.selenium = mozwebqa.selenium
home_pg = MozillaBasePage(mozwebqa)
home_pg.open(url)

for x in home_pg.header_links:
Expand Down Expand Up @@ -79,7 +79,7 @@ def test_header_and_footer_links(self, testsetup, url="/firefox/fx/"):
print home_pg.get_text(x)
print home_pg.is_element_present(x)

def test_all_page_header_and_footer_links(self, testsetup):
def test_all_page_header_and_footer_links(self, mozwebqa):
urls = [
"/firefox/security/",
"/firefox/performance/",
Expand Down Expand Up @@ -107,11 +107,11 @@ def test_all_page_header_and_footer_links(self, testsetup):

for x in urls:
print x
self.test_header_and_footer_links(testsetup, url=x)
self.test_header_and_footer_links(mozwebqa, url=x)

def test_download_buttons(self, testsetup, url="/firefox/features/"):
self.selenium = testsetup.selenium
home_pg = MozillaBasePage(testsetup)
def test_download_buttons(self, mozwebqa, url="/firefox/features/"):
self.selenium = mozwebqa.selenium
home_pg = MozillaBasePage(mozwebqa)
home_pg.open(url)
for x in home_pg.get_upper_download_links:
print home_pg.get_text(x)
Expand Down
12 changes: 6 additions & 6 deletions test_customize.py
Expand Up @@ -45,19 +45,19 @@

class TestCustomize:

def test_customize_icons(self, testsetup):
self.selenium = testsetup.selenium
customize_pg = CustomizePage(testsetup)
def test_customize_icons(self, mozwebqa):
self.selenium = mozwebqa.selenium
customize_pg = CustomizePage(mozwebqa)
customize_pg.open("/en-US/firefox/customize/")
Assert.true(customize_pg.plugins_icon)
Assert.true(customize_pg.interface_icon)
Assert.true(customize_pg.sync_icon)
Assert.true(customize_pg.style_icon)
Assert.true(customize_pg.addons_icon)

def test_customize_images(self, testsetup):
self.selenium = testsetup.selenium
customize_pg = CustomizePage(testsetup)
def test_customize_images(self, mozwebqa):
self.selenium = mozwebqa.selenium
customize_pg = CustomizePage(mozwebqa)
customize_pg.open("/en-US/firefox/customize/")
#Assert.true(customize_pg.style_image)
Assert.true(customize_pg.plugins_image)
Expand Down
19 changes: 9 additions & 10 deletions test_download.py
Expand Up @@ -17,7 +17,7 @@
#
# The Initial Developer of the Original Code is
# Mozilla.
# Portions created by the Initial Developer are Copyright (C) 2010
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s): Raymond Etornam Agbeame
Expand Down Expand Up @@ -46,38 +46,37 @@


@pytest.mark.skip_selenium

class MyOpener(FancyURLopener):
version = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.872.0 Safari/535.2'


class TestDownload(object):

def test_osx_download_button_returns_status_code_200(self, testsetup):
html = BeautifulStoneSoup(urllib2.urlopen('%s/products/download.html' % testsetup.base_url))
def test_osx_download_button_returns_status_code_200(self, mozwebqa):
html = BeautifulStoneSoup(urllib2.urlopen('%s/products/download.html' % mozwebqa.base_url))
link = html.find('li', 'os_osx').a['href']
print link
response = urllib2.urlopen(link)
Assert.equal(response.code, 200)

def test_linux_download_button_returns_status_code_200(self, testsetup):
html = BeautifulStoneSoup(urllib2.urlopen('%s/products/download.html' % testsetup.base_url))
def test_linux_download_button_returns_status_code_200(self, mozwebqa):
html = BeautifulStoneSoup(urllib2.urlopen('%s/products/download.html' % mozwebqa.base_url))
link = html.find('li', 'os_linux').a['href']
print link
response = urllib2.urlopen(link)
Assert.equal(response.code, 200)

def test_windows_download_button_returns_status_code_200(self, testsetup):
html = BeautifulStoneSoup(urllib2.urlopen('%s/products/download.html' % testsetup.base_url))
def test_windows_download_button_returns_status_code_200(self, mozwebqa):
html = BeautifulStoneSoup(urllib2.urlopen('%s/products/download.html' % mozwebqa.base_url))
link = html.find('li', 'os_windows').a['href']
print link
response = urllib2.urlopen(link)
Assert.equal(response.code, 200)

def test_download_button_returns_status_code_200_using_chrome(self, testsetup):
def test_download_button_returns_status_code_200_using_google_chrome(self, mozwebqa):
'''https://bugzilla.mozilla.org/show_bug.cgi?id=672713'''
myopener = MyOpener()
html = BeautifulStoneSoup(myopener.open('%s/products/download.html' % testsetup.base_url))
html = BeautifulStoneSoup(myopener.open('%s/products/download.html' % mozwebqa.base_url))
link = html.find('li', 'os_windows').a['href']
print link
response = urllib2.urlopen(link)
Expand Down
4 changes: 2 additions & 2 deletions test_features.py
Expand Up @@ -42,8 +42,8 @@

class TestFeatures:

def test_page(self, testsetup):
features_pg = FeaturesPage(testsetup)
def test_page(self, mozwebqa):
features_pg = FeaturesPage(mozwebqa)
features_pg.open("/firefox/features/")
Assert.true(features_pg.made_easy)
Assert.true(features_pg.high_performance)
Expand Down
6 changes: 3 additions & 3 deletions test_mobile.py
Expand Up @@ -44,9 +44,9 @@

class TestMobile:

def test_sub_sections_are_present(self, testsetup):
self.selenium = testsetup.selenium
mobile_pg = MobilePage(testsetup)
def test_sub_sections_are_present(self, mozwebqa):
self.selenium = mozwebqa.selenium
mobile_pg = MobilePage(mozwebqa)
mobile_pg.open('/mobile/')
Assert.true(mobile_pg.android_header_text)
Assert.true(mobile_pg.iphone_header_text)
Expand Down
8 changes: 4 additions & 4 deletions test_newsletter.py
Expand Up @@ -45,17 +45,17 @@
class TestNewsletter:

@xfail(reason="Bug 663528 - Build email preference center on mozilla.com")
def test_subscribe_to_newsletter_succeeds(self, testsetup):
newsletter_pg = NewsletterPage(testsetup)
def test_subscribe_to_newsletter_succeeds(self, mozwebqa):
newsletter_pg = NewsletterPage(mozwebqa)
newsletter_pg.go_to_newsletter_page()
newsletter_pg.type_email('me@example.com')
newsletter_pg.agree_to_privacy_policy()
newsletter_pg.click_sign_me_up()
Assert.true(newsletter_pg.is_thanks_for_subscribing_visible)

@xfail(reason="Bug 663528 - Build email preference center on mozilla.com")
def test_subscribe_to_newsletter_fails_if_user_does_not_agree_to_privacy_policy(self, testsetup):
newsletter_pg = NewsletterPage(testsetup)
def test_subscribe_to_newsletter_fails_if_user_does_not_agree_to_privacy_policy(self, mozwebqa):
newsletter_pg = NewsletterPage(mozwebqa)
newsletter_pg.go_to_newsletter_page()
newsletter_pg.type_email('me@example.com')
newsletter_pg.click_sign_me_up()
Expand Down
12 changes: 6 additions & 6 deletions test_performance.py
Expand Up @@ -45,16 +45,16 @@

class TestPerformance:

def test_performance_icons(self, testsetup):
self.selenium = testsetup.selenium
performance_pg = PerformancePage(testsetup)
def test_performance_icons(self, mozwebqa):
self.selenium = mozwebqa.selenium
performance_pg = PerformancePage(mozwebqa)
performance_pg.open("/firefox/performance/")
Assert.true(performance_pg.video_overlay)
Assert.true(performance_pg.perf_web_ico)
Assert.true(performance_pg.perf_hardware_ico)

def test_performance_images(self, testsetup):
self.selenium = testsetup.selenium
performance_pg = PerformancePage(testsetup)
def test_performance_images(self, mozwebqa):
self.selenium = mozwebqa.selenium
performance_pg = PerformancePage(mozwebqa)
performance_pg.open("/firefox/performance/")
Assert.true(performance_pg.perf_hardware_img)

0 comments on commit 44b18d8

Please sign in to comment.