Skip to content
Browse files

merging in conflicts for webdriver switch

  • Loading branch information...
1 parent d9aaf81 commit c94425b2d5950627d61c26e1d242fd5d87c81ee6 @Marlena Marlena committed Dec 2, 2011
View
2 mozwebqa.cfg
@@ -1,3 +1,3 @@
[DEFAULT]
-api = rc
+api = webdriver
baseurl = https://addons-dev.allizom.org
View
2 pages/__init__.py
@@ -21,7 +21,7 @@
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
-# Bebe <florin.strugariu@softvision.ro>
+# Bebe <florin.strugariu@softvision.ro>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
View
73 pages/addons_site.py
@@ -47,96 +47,87 @@
import re
+from selenium.webdriver.common.by import By
+from selenium.webdriver.common.action_chains import ActionChains
+
from pages.base import Base
class WriteReviewBlock(Base):
- _add_review_input_field_locator = "id=id_body"
- _add_review_input_rating_locator = "css=span[class='ratingwidget stars stars-0'] > label > input"
- _add_review_submit_button_locator = "css=#review-box input[type=submit]"
+ _add_review_input_field_locator = (By.ID, "id_body")
+ _add_review_input_rating_locator = (By.CSS_SELECTOR, "span[class='ratingwidget stars stars-0'] > label")
+ _add_review_submit_button_locator = (By.CSS_SELECTOR, "#review-box input[type=submit]")
- _add_review_box = 'css=#review-box'
+ _add_review_box = (By.CSS_SELECTOR, '#review-box')
def enter_review_with_text(self, text):
- self.selenium.type(self._add_review_input_field_locator, text)
+ self.selenium.find_element(*self._add_review_input_field_locator).send_keys(text)
def set_review_rating(self, rating):
- locator = "%s[value=%s]" % (self._add_review_input_rating_locator, rating)
- self.selenium.click(locator)
+ locator = self.selenium.find_element(self._add_review_input_rating_locator[0],
+ '%s[data-stars="%s"]' % (self._add_review_input_rating_locator[1], rating))
+ ActionChains(self.selenium).move_to_element(locator).\
+ click().perform()
def click_to_save_review(self):
- self.wait_for_element_visible(self._add_review_submit_button_locator)
- self.selenium.click(self._add_review_submit_button_locator)
+ self.selenium.find_element(*self._add_review_submit_button_locator).click()
return ViewReviews(self.testsetup)
@property
def is_review_box_visible(self):
- return self.selenium.is_visible(self._add_review_box)
+ return self.is_element_visible(*self._add_review_box)
class ViewReviews(Base):
- _review_locator = "css=div.primary div.review"
-
- def review(self, index=0):
- """ Returns review object with index. """
- return self.ReviewSnippet(self.testsetup, index)
+ _review_locator = (By.CSS_SELECTOR, "div.primary div.review")
+ @property
def reviews(self):
- """ Returns all reviews on the page. """
- return [self.ReviewSnippet(self.testsetup, i) for i in
- range(self.selenium.get_css_count(self._review_locator))]
+ """ Returns review object with index. """
+ return [self.ReviewSnippet(self.testsetup, element) for element in self.selenium.find_elements(*self._review_locator)]
class ReviewSnippet(Base):
- _review_locator = "css=#reviews > .review"
- _review_text_locator = ".description"
- _review_rating_locator = "span[itemprop=rating]"
- _review_author_locator = "a:not(.permalink)"
- _review_date_locator = ".byline"
+ _review_text_locator = (By.CSS_SELECTOR, ".description")
+ _review_rating_locator = (By.CSS_SELECTOR, "span[itemprop=rating]")
+ _review_author_locator = (By.CSS_SELECTOR, "a:not(.permalink)")
+ _review_date_locator = (By.CSS_SELECTOR, ".byline")
- def __init__(self, testsetup, index):
+ def __init__(self, testsetup, element):
Base.__init__(self, testsetup)
- self.index = index
-
- def absolute_locator(self, relative_locator):
- return "%s:nth(%s) %s" % (self._review_locator,
- self.index, relative_locator)
+ self._root_element = element
@property
def text(self):
- text_locator = self.absolute_locator(self._review_text_locator)
- return self.selenium.get_text(text_locator)
+ return self._root_element.find_element(*self._review_text_locator).text
@property
def rating(self):
- _rating_locator = self.absolute_locator(self._review_rating_locator)
- return int(self.selenium.get_text(_rating_locator))
+ return int(self._root_element.find_element(*self._review_rating_locator).text)
@property
def author(self):
- author_locator = self.absolute_locator(self._review_author_locator)
- return self.selenium.get_text(author_locator)
+ return self._root_element.find_element(*self._review_author_locator).text
@property
def date(self):
- date_locator = self.absolute_locator(self._review_date_locator)
- date = self.selenium.get_text(date_locator)
+ date = self._root_element.find_element(*self._review_date_locator).text
# we need to parse the string first to get date
date = re.match('^(.+on\s)([A-Za-z]+\s[\d]+,\s[\d]+)', date)
return date.group(2)
class UserFAQ(Base):
- _license_question_locator = "css=#license"
- _license_answer_locator = "css=#license + dd"
+ _license_question_locator = (By.CSS_SELECTOR, '#license')
+ _license_answer_locator = (By.CSS_SELECTOR, '#license + dd')
@property
def license_question(self):
- return self.selenium.get_text(self._license_question_locator)
+ return self.selenium.find_element(*self._license_question_locator).text
@property
def license_answer(self):
- return self.selenium.get_text(self._license_answer_locator)
+ return self.selenium.find_element(*self._license_answer_locator).text
View
270 pages/base.py
@@ -41,101 +41,59 @@
import re
-from pages.page import Page
from datetime import datetime
-from string import capitalize
+from selenium.webdriver.common.by import By
+from selenium.webdriver.common.action_chains import ActionChains
+from selenium.webdriver.support.ui import WebDriverWait
+
+from pages.page import Page
class Base(Page):
- _next_link_locator = "css=.paginator .rel > a:nth(2)"
- _previous_link_locator = "css=.paginator .rel > a:nth(1)"
- _current_page_locator = "css=.paginator .num > a:nth(0)"
- _last_page_link_locator = "css=.paginator .rel > a:nth(3)"
- _first_page_link_locator = "css=.paginator .rel > a:nth(0)"
- _results_displayed_text_locator = "css=.paginator .pos"
-
+ _current_page_locator = (By.CSS_SELECTOR, ".paginator .num > a:nth-child(1)")
- _amo_logo_link_locator = "css=.site-title a"
- _amo_logo_image_locator = "css=.site-title img"
+ _amo_logo_link_locator = (By.CSS_SELECTOR, ".site-title a")
+ _amo_logo_image_locator = (By.CSS_SELECTOR, ".site-title img")
- _mozilla_logo_link_locator = "css=#global-header-tab a"
+ _mozilla_logo_link_locator = (By.CSS_SELECTOR, "#global-header-tab a")
- _breadcrumbs_locator = "css=#breadcrumbs>ol>li"
+ _breadcrumbs_locator = (By.CSS_SELECTOR, "#breadcrumbs > ol li")
+ _footer_locator = (By.CSS_SELECTOR, "#footer")
def login(self, user="default"):
- login = self.header.click_login()
+ #login = self.header.click_login()
+
+ #this get is a temporary fix before migrating in browserid compatibility
+ from pages.user import Login
+ login = Login(self.testsetup)
+ login.selenium.get(self.base_url + '/en-US/firefox/users/login')
+
login.login_user(user)
@property
def page_title(self):
- return self.selenium.get_title()
+ WebDriverWait(self.selenium, 10).until(lambda s: self.selenium.title)
+ return self.selenium.title
@property
def amo_logo_title(self):
- return self.selenium.get_attribute("%s@title" % self._amo_logo_link_locator)
-
- @property
- def is_amo_logo_visible(self):
- return self.selenium.is_visible(self._amo_logo_link_locator)
+ return self.selenium.find_element(*self._amo_logo_link_locator).get_attribute('title')
@property
def amo_logo_image_source(self):
- return self.selenium.get_attribute("%s@src" % self._amo_logo_image_locator)
-
- @property
- def is_amo_logo_image_visible(self):
- return self.selenium.is_visible(self._amo_logo_image_locator)
+ return self.selenium.find_element(*self._amo_logo_image_locator).get_attribute('src')
@property
def is_mozilla_logo_visible(self):
- return self.selenium.is_visible(self._mozilla_logo_link_locator)
+ return self.is_element_visible(*self._mozilla_logo_link_locator)
def click_mozilla_logo(self):
- self.selenium.click(self._mozilla_logo_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
-
- def page_forward(self):
- self.selenium.click(self._next_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
-
- def page_back(self):
- self.selenium.click(self._previous_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
-
- @property
- def is_prev_link_enabled(self):
- button = self.selenium.get_attribute(self._previous_link_locator + "%s" % "@class")
- return not ("disabled" in button)
-
- @property
- def is_prev_link_visible(self):
- return self.selenium.is_visible(self._previous_link_locator)
-
- @property
- def is_next_link_enabeld(self):
- button = self.selenium.get_attribute(self._next_link_locator + "%s" % "@class")
- return not("disabled" in button)
-
- @property
- def is_next_link_visible(self):
- return self.selenium.is_visible(self._next_link_locator)
+ self.selenium.find_element(*self._mozilla_logo_link_locator).click()
@property
def current_page(self):
- return int(self.selenium.get_text(self._current_page_locator))
-
- @property
- def results_displayed(self):
- return self.selenium.get_text(self._results_displayed_text_locator)
-
- def go_to_last_page(self):
- self.selenium.click(self._last_page_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
-
- def go_to_first_page(self):
- self.selenium.click(self._first_page_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ return int(self.selenium.find_element(*self._current_page_locator).text)
def credentials_of_user(self, user):
return self.parse_yaml_file(self.credentials)[user]
@@ -145,22 +103,11 @@ def header(self):
return Base.HeaderRegion(self.testsetup)
@property
- def breadcrumb_name(self):
- return self.selenium.get_text("%s > span" % self._breadcrumbs_locator)
-
- @property
def breadcrumbs(self):
- return [self.BreadcrumbsRegion(self.testsetup, i) for i in range(self.breadcrumbs_count)]
+ return [self.BreadcrumbsRegion(self.testsetup, element)
+ for element in self.selenium.find_elements(*self._breadcrumbs_locator)]
- @property
- def breadcrumbs_count(self):
- return self.selenium.get_css_count(self._breadcrumbs_locator)
-
- @property
- def is_breadcrumb_menu_visible(self):
- return self.selenium.is_visible(self._breadcrumbs_locator)
-
- def _extract_iso_dates(self, xpath_locator, date_format, count):
+ def _extract_iso_dates(self, date_format, *locator):
"""
Returns a list of iso formatted date strings extracted from
the text elements matched by the given xpath_locator and
@@ -177,25 +124,21 @@ def _extract_iso_dates(self, xpath_locator, date_format, count):
['2010-05-09T00:00:00','2011-06-11T00:00:00']
"""
- addon_dates = [
- self.selenium.get_text("xpath=(%s)[%d]" % (xpath_locator, i))
- for i in xrange(1, count + 1)
- ]
+ addon_dates = [element.text for element in self.selenium.find_elements(*locator)]
+
iso_dates = [
datetime.strptime(s, date_format).isoformat()
for s in addon_dates
]
return iso_dates
- def _extract_integers(self, xpath_locator, regex_pattern, count):
+ def _extract_integers(self, regex_pattern, *locator):
"""
Returns a list of integers extracted from the text elements
matched by the given xpath_locator and regex_pattern.
"""
- addon_numbers = [
- self.selenium.get_text("xpath=(%s)[%d]" % (xpath_locator, i))
- for i in xrange(1, count + 1)
- ]
+ addon_numbers = [element.text for element in self.selenium.find_elements(*locator)]
+
integer_numbers = [
int(re.search(regex_pattern, str(x).replace(",", "")).group(1))
for x in addon_numbers
@@ -205,148 +148,103 @@ def _extract_integers(self, xpath_locator, regex_pattern, count):
class HeaderRegion(Page):
#other applications
- _other_applications_locator = "id=other-apps"
- _other_apps_list_locator = "css=ul.other-apps"
- _app_thunderbird = "css=#app-thunderbird a"
+ _other_applications_locator = (By.ID, "other-apps")
#Search box
- _search_button_locator = "css=.search-button"
- _search_textbox_locator = "name=q"
+ _search_button_locator = (By.CSS_SELECTOR, ".search-button")
+ _search_textbox_locator = (By.NAME, "q")
- #Not LogedIn
- _login_locator = "css=#aux-nav li.account a:nth(1)"
- _register_locator = "css=#aux-nav li.account a:nth(0)"
+ #Not LoggedIn
+ _login_locator = (By.CSS_SELECTOR, "#aux-nav li.account a:nth-child(2)")
+ _register_locator = (By.CSS_SELECTOR, "#aux-nav li.account a:nth-child(1)")
- #LogedIn
- _account_controller_locator = 'css=#aux-nav .account .user'
- _account_dropdown_locator = "css=#aux-nav .account ul"
- _logout_locator = 'css=li.nomenu.logout > a'
+ #LoggedIn
+ _account_controller_locator = (By.CSS_SELECTOR, "#aux-nav .account a.user")
+ _account_dropdown_locator = (By.CSS_SELECTOR, "#aux-nav .account ul")
+ _logout_locator = (By.CSS_SELECTOR, "li.nomenu.logout > a")
def site_nav(self, lookup):
- if type(lookup) != int:
- lookup = capitalize(lookup)
from pages.regions.header_menu import HeaderMenu
return HeaderMenu(self.testsetup, lookup)
- #TODO:hover other apps
- def click_other_applications(self):
- self.selenium.click(self._other_applications_locator)
-
- def click_thunderbird(self):
- self.selenium.click(self._app_thunderbird)
- self.selenium.wait_for_page_to_load(self.timeout)
+ def click_other_application(self, other_app):
+ hover_locator = self.selenium.find_element(*self._other_applications_locator)
+ app_locator = self.selenium.find_element(By.CSS_SELECTOR,
+ "#app-%s" % other_app.lower())
+ ActionChains(self.selenium).move_to_element(hover_locator).\
+ move_to_element(app_locator).\
+ click().perform()
- def is_thunderbird_visible(self):
- return self.is_element_present(self._app_thunderbird)
+ def is_other_application_visible(self, other_app):
+ hover_locator = self.selenium.find_element(*self._other_applications_locator)
+ app_locator = (By.CSS_SELECTOR, "#app-%s" % other_app.lower())
+ ActionChains(self.selenium).move_to_element(hover_locator).perform()
+ return self.is_element_visible(*app_locator)
def search_for(self, search_term):
- self.selenium.type(self._search_textbox_locator, search_term)
- self.selenium.click(self._search_button_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ search_box = self.selenium.find_element(*self._search_textbox_locator)
+ search_box.send_keys(search_term)
+ self.selenium.find_element(*self._search_button_locator).click()
from pages.search import SearchHome
return SearchHome(self.testsetup)
@property
def search_field_placeholder(self):
- return self.selenium.get_attribute(self._search_textbox_locator + '@placeholder')
-
- def click_my_account(self):
- self.selenium.click(self._account_controller_locator)
- self.wait_for_element_visible(self._account_dropdown_locator)
+ return self.selenium.find_element(*self._search_textbox_locator).get_attribute('placeholder')
def click_login(self):
- self.selenium.click(self._login_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._login_locator).click()
from pages.user import Login
return Login(self.testsetup)
def click_logout(self):
- self.selenium.click(self._logout_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._logout_locator).click()
def click_edit_profile(self):
- self.click_my_account
- self.selenium.click('%s > li:nth(1) a' % self._account_dropdown_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ hover_element = self.selenium.find_element(*self._account_controller_locator)
+ click_element = self.selenium.find_element(self._account_dropdown_locator[0],
+ '%s > li:nth-child(2) a' % self._account_dropdown_locator[1])
+ ActionChains(self.selenium).move_to_element(hover_element).\
+ move_to_element(click_element).\
+ click().perform()
+
from pages.user import EditProfile
return EditProfile(self.testsetup)
def click_view_profile(self):
- self.click_my_account
- self.selenium.click('%s > li:nth(0) a' % self._account_dropdown_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ hover_element = self.selenium.find_element(*self._account_controller_locator)
+ click_element = self.selenium.find_element(self._account_dropdown_locator[0],
+ '%s > li:nth-child(1) a' % self._account_dropdown_locator[1])
+ ActionChains(self.selenium).move_to_element(hover_element).\
+ move_to_element(click_element).\
+ click().perform()
+
from pages.user import ViewProfile
return ViewProfile(self.testsetup)
@property
def is_user_logged_in(self):
try:
- return self.selenium.is_visible(self._account_controller_locator)
+ return self.is_element_visible(*self._account_controller_locator)
except:
return False
- @property
- def other_applications_count(self):
- return int(self.selenium.get_css_count("%s li" % self._other_apps_list_locator))
-
- @property
- def other_applications(self):
- return [self.OtherApplications(self.testsetup, i) for i in range(self.other_applications_count)]
-
- class OtherApplications(Page):
-
- _name_locator = " > a"
- _other_apps_locator = "css=ul.other-apps > li"
-
- def __init__(self, testsetup, lookup):
- Page.__init__(self, testsetup)
- self.lookup = lookup
-
- def absolute_locator(self, relative_locator):
- return self.root_locator + relative_locator
-
- @property
- def root_locator(self):
- if type(self.lookup) == int:
- # lookup by index
- return "%s:nth(%s)" % (self._other_apps_locator, self.lookup)
- else:
- # lookup by name
- return "%s:contains(%s)" % (self._other_apps_locator, self.lookup)
-
- @property
- def name(self):
- return self.selenium.get_text(self.absolute_locator(self._name_locator))
-
- @property
- def is_application_visible(self):
- return self.is_element_present(self.absolute_locator(self._name_locator))
-
- @property
- def index(self):
- return self.lookup
-
class BreadcrumbsRegion(Page):
- _breadcrumb_locator = "css=#breadcrumbs>ol" # Base locator
- _link_locator = " a"
- _link_value_locator = " a@href"
+ _breadcrumb_locator = (By.CSS_SELECTOR, '#breadcrumbs>ol') # Base locator
+ _link_locator = (By.CSS_SELECTOR, ' a')
- def __init__(self, testsetup, lookup):
+ def __init__(self, testsetup, element):
Page.__init__(self, testsetup)
- self.lookup = lookup
-
- def absolute_locator(self, relative_locator=""):
- return "%s>li:nth(%s)%s" % (self._breadcrumb_locator, self.lookup, relative_locator)
+ self._root_element = element
- def click(self):
- self.selenium.click(self.absolute_locator(self._link_locator))
- self.selenium.wait_for_page_to_load(self.timeout)
+ def click_breadcrumb(self):
+ self._root_element.find_element(*self._link_locator).click()
@property
def name(self):
- return self.selenium.get_text(self.absolute_locator())
+ return self._root_element.text
@property
def link_value(self):
- return self.selenium.get_attribute(self.absolute_locator(self._link_value_locator))
+ return self._root_element.find_element(*self._link_locator).get_attribute('href')
View
11 pages/category.py
@@ -21,6 +21,7 @@
# the Initial Developer. All Rights Reserved.
#
# Contributor(s): Marlena Compton <mcompton@mozilla.com>
+# Bebe <florin.strugariu@softvision.ro>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -36,17 +37,15 @@
#
# ***** END LICENSE BLOCK *****
+from selenium.webdriver.common.by import By
+
from pages.base import Base
class Category(Base):
- _category_title_locator = "css=div.island > h1"
-
- @property
- def category_page_title(self):
- return self.selenium.get_title()
+ _category_title_locator = (By.CSS_SELECTOR, "div.island > h1")
@property
def category_header_title(self):
- return self.selenium.get_text(self._category_title_locator)
+ return self.selenium.find_element(*self._category_title_locator).text
View
20 pages/collection.py
@@ -36,6 +36,8 @@
#
# ***** END LICENSE BLOCK *****
+from selenium.webdriver.common.by import By
+
from pages.base import Base
@@ -44,25 +46,25 @@ class Collections(Base):
_page_title = "Featured Collections :: Add-ons for Firefox"
#Search box
- _search_button_locator = "css=button.search-button"
- _search_textbox_locator = "name=q"
- _collection_name = 'css=h2.collection > span'
+ _search_button_locator = (By.CSS_SELECTOR, "button.search-button")
+ _search_textbox_locator = (By.NAME, "q")
+ _collection_name = (By.CSS_SELECTOR, "h2.collection > span")
@property
def collection_name(self):
- return self.selenium.get_text(self._collection_name)
+ return self.selenium.find_element(*self._collection_name).text
def search_for(self, search_term):
- self.selenium.type(self._search_textbox_locator, search_term)
- self.selenium.click(self._search_button_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ search_box = self.selenium.find_element(*self._search_textbox_locator)
+ search_box.send_keys(search_term)
+ self.selenium.find_element(*self._search_button_locator).click()
return CollectionsSearch(self.testsetup)
class CollectionsSearch(Base):
- _results_locator = "css=div.featured-inner div.item"
+ _results_locator = (By.CSS_SELECTOR, "div.featured-inner div.item")
@property
def result_count(self):
- return int(self.selenium.get_css_count(self._results_locator))
+ return len(self.selenium.find_elements(*self._results_locator))
View
576 pages/details.py
@@ -47,80 +47,76 @@
import re
+from urllib2 import urlparse
+from selenium.webdriver.common.by import By
+
from pages.page import Page
from pages.base import Base
-from urllib2 import urlparse
class Details(Base):
- _breadcrumb_locator = "id=breadcrumbs"
- _current_page_breadcrumb_locator = "css=#breadcrumbs > ol > li:nth(2)"
+ _breadcrumb_locator = (By.ID, "breadcrumbs")
#addon informations
- _name_locator = "css=h1.addon"
- _title_locator = "xpath=//h1[@Class='addon']/text()[normalize-space()]"
- _version_number_locator = "css=span.version-number"
- _authors_locator = "//h4[@class='author']/a"
- _summary_locator = "id=addon-summary"
- _ratings_locator = "css=span[itemprop='rating']"
- _install_button_locator = "css=p[class='install-button'] > a"
- _contribute_button_locator = "css=a[id='contribute-button']"
- _rating_locator = "css=span[itemprop='rating']"
- _license_link_locator = "css=.source-license > a"
- _whats_this_license_locator = "css=.license-faq"
- _view_the_source_locator = "css=.source-code"
- _complete_version_history_locator = "css=p.more > a"
- _description_locator = "css=div.prose"
- _register_link_locator = "css=li.account > a"
- _login_link_locator = "css=li.account > a:nth(1)"
- _other_applications_locator = "id=other-apps"
- _other_apps_dropdown_menu_locator = "css=ul.other-apps"
-
- _about_addon_locator = "css=section.primary > h2"
- _more_about_addon_locator = "id=more-about"
- _version_information_locator = "css=#detail-relnotes"
- _version_information_heading_locator = "css=#detail-relnotes > h2"
- _release_version_locator = "css=div.info > h3 > a"
- _source_code_license_information_locator = "css=.source > li > a"
- _reviews_title_locator = "css=#reviews > h2"
- _tags_locator = "id=tagbox"
- _other_addons_header_locator = "css=h2.compact-bottom"
- _other_addons_list_locator = "css=.primary .listing-grid"
- _part_of_collections_locator = "css=#collections-grid"
- _icon_locator = "css=img.icon"
- _featured_image_locator = "css=#addon .featured .screenshot"
- _support_link_locator = "css=a.support"
- _review_details_locator = "css=.review .description"
- _all_reviews_link_locator = "css=a.more-info"
- _review_locator = "css=div.review:not(.reply)"
- _info_link_locator = "css=li > a.scrollto"
- _rating_counter_locator = "css=.grouped_ratings .num_ratings"
- _devs_comments_section_locator = "css=#developer-comments"
-
- _image_locator = "css=#preview.slider li.panel.active a"
- _image_viewer_locator = 'id=lightbox'
+ _title_locator = (By.CSS_SELECTOR, "#addon > hgroup > h1.addon")
+ _version_number_locator = (By.CSS_SELECTOR, "span.version-number")
+ _authors_locator = (By.XPATH, "//h4[@class='author']/a")
+ _summary_locator = (By.ID, "addon-summary")
+ _install_button_locator = (By.CSS_SELECTOR, "p[class='install-button'] > a")
+ _rating_locator = (By.CSS_SELECTOR, "span[itemprop='rating']")
+ _whats_this_license_locator = (By.CSS_SELECTOR, ".license-faq")
+ _view_the_source_locator = (By.CSS_SELECTOR, ".source-code")
+ _complete_version_history_locator = (By.CSS_SELECTOR, "p.more > a")
+ _description_locator = (By.CSS_SELECTOR, "div.prose")
+ _register_link_locator = (By.CSS_SELECTOR, "li.account > a")
+ _login_link_locator = (By.CSS_SELECTOR, "li.account > a:nth-child(2)")
+ _other_applications_locator = (By.ID, "other-apps")
+
+ _about_addon_locator = (By.CSS_SELECTOR, "section.primary > h2")
+ _version_information_locator = (By.CSS_SELECTOR, "#detail-relnotes")
+ _version_information_heading_locator = (By.CSS_SELECTOR, "#detail-relnotes > h2")
+ _version_information_heading_link_locator = (By.CSS_SELECTOR, "#detail-relnotes > h2 > a")
+ _release_version_locator = (By.CSS_SELECTOR, "div.info > h3 > a")
+ _source_code_license_information_locator = (By.CSS_SELECTOR, ".source > li > a")
+ _reviews_title_locator = (By.CSS_SELECTOR, "#reviews > h2")
+ _tags_locator = (By.ID, "tagbox")
+ _other_addons_header_locator = (By.CSS_SELECTOR, "h2.compact-bottom")
+ _other_addons_list_locator = (By.CSS_SELECTOR, ".primary .listing-grid")
+ _part_of_collections_header_locator = (By.CSS_SELECTOR, "#collections-grid h2")
+ _part_of_collections_list_locator = (By.CSS_SELECTOR, "#collections-grid section li")
+ _icon_locator = (By.CSS_SELECTOR, "img.icon")
+ _support_link_locator = (By.CSS_SELECTOR, "a.support")
+ _review_details_locator = (By.CSS_SELECTOR, ".review .description")
+ _all_reviews_link_locator = (By.CSS_SELECTOR, "a.more-info")
+ _review_locator = (By.CSS_SELECTOR, "div.review:not(.reply)")
+ _info_link_locator = (By.CSS_SELECTOR, "li > a.scrollto")
+ _rating_counter_locator = (By.CSS_SELECTOR, ".grouped_ratings .num_ratings")
+
+ _devs_comments_section_locator = (By.CSS_SELECTOR, "#developer-comments")
+ _devs_comments_title_locator = (By.CSS_SELECTOR, "#developer-comments h2")
+ _devs_comments_message_locator = (By.CSS_SELECTOR, "#developer-comments div.content")
#more about this addon
- _additional_images_locator = "css=#addon .article .screenshot"
- _website_locator = "css=.links a.home"
+ _website_locator = (By.CSS_SELECTOR, ".links a.home")
#other_addons
- _other_addons_by_author_locator = 'css=#author-addons'
- _reviews_locator = "css=#reviews"
- _add_review_link_locator = "id=add-review"
+ _other_addons_by_author_locator = (By.CSS_SELECTOR, "#author-addons > ul.listing-grid > section li")
+ _other_addons_by_author_text_locator = (By.CSS_SELECTOR, '#author-addons > h2')
+ _reviews_locator = (By.CSS_SELECTOR, "section#reviews div")
+ _add_review_link_locator = (By.ID, "add-review")
- _add_to_collection_locator = "css=.collection-add.widget.collection"
- _add_to_collection_widget_locator = "id=add-to-collection"
- _add_to_collection_widget_button_locator = "css=.register-button .button"
- _add_to_collection_widget_login_link_locator = 'css=.collection-add-login a:nth(1)'
- _add_to_collection_widget_create_new_locator = 'css=#ajax_new_collection a'
+ _add_to_collection_locator = (By.CSS_SELECTOR, ".collection-add.widget.collection")
+ _add_to_collection_widget_button_locator = (By.CSS_SELECTOR, ".collection-add-login .register-button .button")
+ _add_to_collection_widget_login_link_locator = (By.CSS_SELECTOR, "div.collection-add-login p:nth-child(3) > a")
- _share_this_addon_locator = "css=.share.widget"
- _share_this_addon_widget_locator = "id=sharing-popup"
- _share_link_locator = "css=.share-link a"
- _share_count_locator = "css=.share-count"
+ _development_channel_locator = (By.CSS_SELECTOR, "#beta-channel")
+ _development_channel_title_locator = (By.CSS_SELECTOR, "#beta-channel h2")
+ _development_channel_content_locator = (By.CSS_SELECTOR, "#beta-channel > div.content")
- _development_channel_locator = "css=#beta-channel"
+ _next_link_locator = (By.CSS_SELECTOR, ".paginator .rel > a:nth-child(3)")
+ _previous_link_locator = (By.CSS_SELECTOR, ".paginator .rel > a:nth-child(2)")
+ _last_page_link_locator = (By.CSS_SELECTOR, ".paginator .rel > a:nth-child(4)")
+ _first_page_link_locator = (By.CSS_SELECTOR, ".paginator .rel > a:nth-child(1)")
def __init__(self, testsetup, addon_name=None):
#formats name for url
@@ -129,298 +125,235 @@ def __init__(self, testsetup, addon_name=None):
self.addon_name = addon_name.replace(" ", "-")
self.addon_name = re.sub(r'[^A-Za-z0-9\-]', '', self.addon_name).lower()
self.addon_name = self.addon_name[:27]
- self.selenium.open("%s/addon/%s" % (self.site_version, self.addon_name))
- self.wait_for_element_present(self._reviews_locator)
+ self.selenium.get("%s/addon/%s" % (self.base_url, self.addon_name))
@property
def _page_title(self):
return "%s :: Add-ons for Firefox" % self.title
@property
def title(self):
- return self.selenium.get_text(self._title_locator)
+ base = self.selenium.find_element(*self._title_locator).text
+ '''base = "firebug 1.8.9" we will have to remove version number for it'''
+ return base.replace(self.version_number, '').strip()
@property
def has_reviews(self):
- return self.selenium.get_css_count(self._review_details_locator) > 0
-
- @property
- def is_all_reviews_link_visible(self):
- return self.selenium.is_visible(self._all_reviews_link_locator)
+ return self.review_count > 0
def click_all_reviews_link(self):
- self.selenium.click(self._all_reviews_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._all_reviews_link_locator).click()
@property
def review_count(self):
- return self.selenium.get_css_count(self._review_locator)
+ return len(self.selenium.find_elements(*self._review_locator))
@property
def breadcrumb(self):
- return self.selenium.get_text(self._breadcrumb_locator)
-
- @property
- def current_page_breadcrumb(self):
- return self.selenium.get_text(self._current_page_breadcrumb_locator)
-
- @property
- def page_title(self):
- return self.selenium.get_title()
-
- @property
- def name(self):
- return self.selenium.get_text(self._name_locator)
+ return self.selenium.find_element(*self._breadcrumb_locator).text
@property
def version_number(self):
- return self.selenium.get_text(self._version_number_locator)
+ return self.selenium.find_element(*self._version_number_locator).text
@property
def source_code_license_information(self):
- return self.selenium.get_text(self._source_code_license_information_locator)
+ return self.selenium.find_element(*self._source_code_license_information_locator).text
@property
def authors(self):
- return [self.selenium.get_text(self._authors_locator + "[ % s]" % (i + 1))
- for i in range(self.selenium.get_xpath_count(self._authors_locator))]
+ return [element.text for element in self.selenium.find_elements(*self._authors_locator)]
@property
def summary(self):
- return self.selenium.get_text(self._summary_locator)
+ return self.selenium.find_element(*self._summary_locator).text
@property
def rating(self):
- return self.selenium.get_text(self._rating_locator)
+ return self.selenium.find_element(*self._rating_locator).text
def click_whats_this_license(self):
- self.selenium.click(self._whats_this_license_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._whats_this_license_locator).click()
from pages.addons_site import UserFAQ
return UserFAQ(self.testsetup)
@property
- def license_site(self):
- return self.selenium.get_attribute("%s@href" % self._license_link_locator)
-
- @property
- def is_license_link_visible(self):
- return self.selenium.is_visible(self._license_link_locator)
-
- @property
def description(self):
- return self.selenium.get_text(self._description_locator)
+ return self.selenium.find_element(*self._description_locator).text
@property
def register_link(self):
- return self.selenium.get_text(self._register_link_locator)
+ return self.selenium.find_element(*self._register_link_locator).text
@property
def login_link(self):
- return self.selenium.get_text(self._login_link_locator)
+ return self.selenium.find_element(*self._login_link_locator).text
@property
def other_apps(self):
- return self.selenium.get_text(self._other_applications_locator)
+ return self.selenium.find_element(*self._other_applications_locator).text
@property
def version_information_heading(self):
- return self.selenium.get_text(self._version_information_heading_locator)
+ return self.selenium.find_element(*self._version_information_heading_locator).text
@property
- def version_information(self):
- return self.selenium.get_attribute("%s > a@href" % self._version_information_heading_locator)
+ def version_information_href(self):
+ return self.selenium.find_element(*self._version_information_heading_link_locator).get_attribute('href')
@property
def release_version(self):
- return self.selenium.get_text(self._release_version_locator)
+ return self.selenium.find_element(*self._release_version_locator).text
@property
def about_addon(self):
- return self.selenium.get_text(self._about_addon_locator)
+ return self.selenium.find_element(*self._about_addon_locator).text
@property
def review_title(self):
- return self.selenium.get_text(self._reviews_title_locator)
+ return self.selenium.find_element(*self._reviews_title_locator).text
+
+ @property
+ def review_details(self):
+ return self.selenium.find_element(*self._review_details_locator).text
@property
def often_used_with_header(self):
- return self.selenium.get_text(self._other_addons_header_locator)
+ return self.selenium.find_element(*self._other_addons_header_locator).text
@property
def devs_comments_title(self):
- return self.selenium.get_text("%s > h2" % self._devs_comments_section_locator)
+ return self.selenium.find_element(*self._devs_comments_title_locator).text
@property
def devs_comments_message(self):
- return self.selenium.get_text("%s div.content" % self._devs_comments_section_locator)
+ return self.selenium.find_element(*self._devs_comments_message_locator).text
- @property
- def is_register_visible(self):
- return self.selenium.is_visible(self._register_link_locator)
-
- @property
- def is_login_visible(self):
- return self.selenium.is_visible(self._login_link_locator)
-
- @property
- def is_other_apps_link_visible(self):
- return self.selenium.is_visible(self._other_applications_locator)
-
- @property
- def is_other_apps_dropdown_menu_visible(self):
- self.click_other_apps()
- return self.selenium.is_visible(self._other_apps_dropdown_menu_locator)
-
- @property
- def is_addon_name_visible(self):
- return self.selenium.is_visible(self._name_locator)
-
- @property
- def is_summary_visible(self):
- return self.selenium.is_visible(self._summary_locator)
-
- @property
- def is_about_addon_visible(self):
- return self.selenium.is_visible(self._about_addon_locator)
-
- @property
- def is_version_information_visible(self):
- return self.selenium.is_visible(self._version_information_locator)
-
- @property
- def is_version_information_heading_visible(self):
- return self.selenium.is_visible(self._version_information_heading_locator)
+ def click_version_information_heading(self):
+ return self.selenium.find_element(*self._version_information_heading_link_locator).click()
@property
def is_version_information_section_expanded(self):
- expand_info = self.selenium.get_attribute("%s@class" % self._version_information_locator)
+ expand_info = self.selenium.find_element(*self._version_information_locator).get_attribute("class")
return ("expanded" in expand_info)
@property
- def is_version_information_content_visible(self):
- return self.selenium.is_visible('%s > div' % self._version_information_locator)
-
- @property
def is_version_information_install_button_visible(self):
- return self.selenium.is_visible("%s p.install-button" % self._version_information_locator)
+ return self.is_element_visible(*self._install_button_locator)
@property
def is_whats_this_license_visible(self):
- return self.selenium.is_visible(self._whats_this_license_locator)
+ return self.is_element_visible(*self._whats_this_license_locator)
@property
def is_source_code_license_information_visible(self):
- return self.selenium.is_visible(self._source_code_license_information_locator)
+ return self.is_element_visible(*self._source_code_license_information_locator)
@property
def is_view_the_source_link_visible(self):
- return self.selenium.is_visible(self._view_the_source_locator)
+ return self.is_element_visible(*self._view_the_source_locator)
@property
def is_complete_version_history_visible(self):
- return self.selenium.is_visible(self._complete_version_history_locator)
-
- def click_complete_version_history(self):
- self.selenium.click(self._complete_version_history_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ return self.is_element_visible(*self._complete_version_history_locator)
@property
- def does_page_scroll_to_version_information_section(self):
- return (self.selenium.get_eval("window.pageYOffset")) > 2000
+ def is_version_information_section_in_view(self):
+ """ Check if the information section is in view.
- @property
- def is_review_title_visible(self):
- return self.selenium.is_visible(self._reviews_title_locator)
+ The script returns the pixels the current document has been scrolled from the
+ upper left corner of the window, vertically.
+ If the offset is > 1000, the page has scrolled to the information section and it
+ is in view.
- @property
- def is_often_used_with_header_visible(self):
- return self.selenium.is_visible(self._other_addons_header_locator)
+ """
+ return (self.selenium.execute_script('return window.pageYOffset')) > 1000
@property
def is_often_used_with_list_visible(self):
- return self.selenium.is_visible(self._other_addons_list_locator)
+ return self.is_element_visible(*self._other_addons_list_locator)
@property
def are_tags_visible(self):
- return self.selenium.is_visible(self._tags_locator)
+ return self.is_element_visible(*self._tags_locator)
- @property
- def is_part_of_collections_header_visible(self):
- return self.selenium.is_visible('%s h2' % self._part_of_collections_locator)
+ def is_devs_comments_section_expanded(self):
+ is_expanded = self.selenium.find_element(*self._devs_comments_section_locator).get_attribute("class")
+ return ("expanded" in is_expanded)
@property
- def is_part_of_collections_list_visible(self):
- return self.selenium.is_visible('%s ul' % self._part_of_collections_locator)
+ def part_of_collections_header(self):
+ return self.selenium.find_element(*self._part_of_collections_header_locator).text
@property
- def is_devs_comments_section_visible(self):
- return self.selenium.is_visible(self._devs_comments_section_locator)
+ def part_of_collections(self):
+ return [self.PartOfCollectionsSnippet(self.testsetup, element)
+ for element in self.selenium.find_elements(*self._part_of_collections_list_locator)]
- def is_devs_comments_section_expanded(self):
- is_expanded = self.selenium.get_attribute("%s@class" % self._devs_comments_section_locator)
- return ("expanded" in is_expanded)
+ def page_forward(self):
+ self.selenium.find_element(*self._next_link_locator).click()
+
+ def page_back(self):
+ self.selenium.find_element(*self._previous_link_locator).click()
+
+ def go_to_last_page(self):
+ self.selenium.find_element(*self._last_page_link_locator).click()
+
+ def go_to_first_page(self):
+ self.selenium.find_element(*self._first_page_link_locator).click()
@property
- def part_of_collections_header(self):
- return self.selenium.get_text('%s h2' % self._part_of_collections_locator)
+ def is_prev_link_enabled(self):
+ button = self.selenium.find_element(*self._previous_link_locator).get_attribute('class')
+ return not ("disabled" in button)
@property
- def part_of_collections_count(self):
- return self.selenium.get_css_count("%s li" % self._part_of_collections_locator)
+ def is_prev_link_visible(self):
+ return self.is_element_visible(*self._previous_link_locator)
- def part_of_collections(self):
- self.wait_for_element_present(self._part_of_collections_locator)
- return [self.PartOfCollectionsSnippet(self.testsetup, i) for i in range(self.part_of_collections_count)]
+ @property
+ def is_next_link_enabled(self):
+ button = self.selenium.find_element(*self._next_link_locator).get_attribute('class')
+ return not("disabled" in button)
+
+ @property
+ def is_next_link_visible(self):
+ return self.is_element_visible(*self._next_link_locator)
class PartOfCollectionsSnippet(Page):
- _collections_locator = "css=#collections-grid li" # Base locator
- _name_locator = " div.summary > h3"
- _link_locator = " > a"
+ _name_locator = (By.CSS_SELECTOR, ' div.summary > h3')
- def __init__(self, testsetup, lookup):
+ def __init__(self, testsetup, element):
Page.__init__(self, testsetup)
- self.lookup = lookup
-
- def absolute_locator(self, relative_locator):
- return self._root_locator + relative_locator
-
- @property
- def _root_locator(self):
- self.wait_for_element_visible(self._collections_locator)
- if type(self.lookup) == int:
- # lookup by index
- return "%s:nth(%s) > div" % (self._collections_locator, self.lookup)
- else:
- # lookup by name
- return "%s:contains(%s) > div" % (self._collections_locator, self.lookup)
+ self._root_element = element
def click_collection(self):
- self.selenium.click(self.absolute_locator(self._link_locator))
- self.selenium.wait_for_page_to_load(self.timeout)
+ self._root_element.click()
from pages.collection import Collections
return Collections(self.testsetup)
@property
def name(self):
- return self.selenium.get_text(self.absolute_locator(self._name_locator))
+ return self._root_element.find_element(*self._name_locator).text
def click_other_apps(self):
- self.selenium.click(self._other_applications_locator)
- self.wait_for_element_visible(self._other_apps_dropdown_menu_locator)
+ self.selenium.find_element(*self._other_applications_locator).click()
@property
def icon_url(self):
- return self.selenium.get_attribute(self._icon_locator + "%s" % "@src")
+ return self.selenium.find_element(*self._icon_locator).get_attribute('src')
@property
def website(self):
- return self.selenium.get_attribute("%s@href" % self._website_locator)
+ return self.selenium.find_element(*self._website_locator).get_attribute('href')
+
+ def click_website_link(self):
+ self.selenium.find_element(*self._website_locator).click()
@property
def support_url(self):
- support_url = self.selenium.get_attribute(self._support_link_locator + "%s" % "@href")
+ support_url = self.selenium.find_element(*self._support_link_locator).get_attribute('href')
match = re.findall("http", support_url)
#staging url
if len(match) > 1:
@@ -435,113 +368,68 @@ def _extract_url_from_link(self, url):
@property
def other_addons_by_authors_text(self):
- self.wait_for_element_present(self._other_addons_by_author_locator)
- return self.selenium.get_text("%s > h2" % self._other_addons_by_author_locator)
+ return self.selenium.find_element(*self._other_addons_by_author_text_locator).text
@property
- def other_addons_count(self):
- self.wait_for_element_present(self._other_addons_by_author_locator)
- return int(self.selenium.get_css_count('%s li' % self._other_addons_by_author_locator))
-
def other_addons(self):
- self.wait_for_element_present(self._other_addons_by_author_locator)
- return [self.OtherAddons(self.testsetup, i) for i in range(self.other_addons_count)]
+ return [self.OtherAddons(self.testsetup, element)
+ for element in self.selenium.find_elements(*self._other_addons_by_author_locator)]
def get_rating_counter(self, rating):
- if rating == 1:
- locator = "%s:nth(4)" % self._rating_counter_locator
- elif rating == 2:
- locator = "%s:nth(3)" % self._rating_counter_locator
- elif rating == 3:
- locator = "%s:nth(2)" % self._rating_counter_locator
- elif rating == 4:
- locator = "%s:nth(1)" % self._rating_counter_locator
- elif rating == 5:
- locator = "%s:nth(0)" % self._rating_counter_locator
- else:
- raise RuntimeError("No such rating %s!" % str(rating))
- return int(self.selenium.get_text(locator))
+ elements = self.selenium.find_elements(*self._rating_counter_locator)
+ try:
+ return int(elements[5 - rating].text)
+ except IndexError:
+ return 0
@property
def previewer(self):
return self.ImagePreviewer(self.testsetup)
def click_add_to_collection_widget(self):
- self.selenium.click(self._add_to_collection_locator)
- self.wait_for_element_visible(self._add_to_collection_widget_locator)
-
- @property
- def is_collection_widget_visible(self):
- return self.selenium.is_visible(self._add_to_collection_widget_locator)
-
- @property
- def is_collection_widget_button_visible(self):
- return self.selenium.is_visible(self._add_to_collection_widget_button_locator)
+ self.selenium.find_element(*self._add_to_collection_locator).click()
@property
def collection_widget_button(self):
- return self.selenium.get_text(self._add_to_collection_widget_button_locator)
-
- @property
- def is_collection_widget_login_link_visible(self):
- return self.selenium.is_visible(self._add_to_collection_widget_login_link_locator)
-
- @property
- def is_collection_widget_create_new_visible(self):
- return self.selenium.is_visible(self._add_to_collection_widget_create_new_locator)
+ return self.selenium.find_element(*self._add_to_collection_widget_button_locator).text
@property
def collection_widget_login_link(self):
- return self.selenium.get_text(self._add_to_collection_widget_login_link_locator)
-
- @property
- def share_this_addon_widget_link(self):
- return self.selenium.get_text(self._share_this_addon_locator)
-
- def click_share_this_addon_widget(self):
- self.selenium.click(self._share_this_addon_locator)
- self.wait_for_element_visible(self._share_this_addon_widget_locator)
-
- @property
- def share_links_count(self):
- return self.selenium.get_css_count(self._share_link_locator)
-
- def share_link(self, link_no):
- return self.selenium.get_text("%s:nth(%s)" % (self._share_link_locator, link_no))
-
- def share_count(self, link_no):
- return self.selenium.get_text("%s:nth(%s)" % (self._share_count_locator, link_no))
+ return self.selenium.find_element(*self._add_to_collection_widget_login_link_locator).text
class ImagePreviewer(Page):
#navigation
- _next_locator = 'css=section.previews.carousel > a.next'
- _prev_locator = 'css=section.previews.carousel > a.prev'
+ _next_locator = (By.CSS_SELECTOR, 'section.previews.carousel > a.next')
+ _prev_locator = (By.CSS_SELECTOR, 'section.previews.carousel > a.prev')
- _image_locator = 'css=#preview'
+ _image_locator = (By.CSS_SELECTOR, '#preview li')
def next_set(self):
- self.selenium.click(self._next_locator)
+ self.selenium.find_element(*self._next_locator).click()
def prev_set(self):
- self.selenium.click(self._prev_locator)
+ self.selenium.find_element(*self._prev_locator).click()
- def click_image(self, image_no=0):
- self.selenium.click('%s li:nth(%s) a' % (self._image_locator, image_no))
+ def click_image(self, image_no=1):
+ self.selenium.find_element(self._image_locator[0],
+ '%s:nth-child(%s) a' % (self._image_locator[1], image_no)).click()
from pages.regions.image_viewer import ImageViewer
image_viewer = ImageViewer(self.testsetup)
image_viewer.wait_for_image_viewer_to_finish_animating()
return image_viewer
def image_title(self, image_no):
- return self.selenium.get_attribute('%s li:nth(%s) a@title' % (self._image_locator, image_no))
+ return self.selenium.find_element(self._image_locator[0],
+ '%s:nth-child(%s) a' % (self._image_locator[1], image_no + 1)).get_attribute('title')
def image_link(self, image_no):
- return self.selenium.get_attribute('%s li:nth(%s) a img@src' % (self._image_locator, image_no))
+ return self.selenium.find_element(self._image_locator[0],
+ '%s:nth-child(%s) a img' % (self._image_locator[1], image_no + 1)).get_attribute('src')
@property
def image_count(self):
- return int(self.selenium.get_css_count('%s li' % self._image_locator))
+ return len(self.selenium.find_elements(*self._image_locator))
@property
def image_set_count(self):
@@ -550,141 +438,79 @@ def image_set_count(self):
else:
return self.image_count / 3 + 1
- def review(self, lookup):
- return self.DetailsReviewSnippet(self.testsetup, lookup)
-
- def reviews(self):
- return [self.DetailsReviewSnippet(self.testsetup, i) for i in range(self.reviews_count)]
+ def review(self, element):
+ return self.DetailsReviewSnippet(self.testsetup, element)
@property
- def reviews_count(self):
- self.wait_for_element_visible(self._reviews_locator)
- return int(self.selenium.get_css_count("%s div" % self._reviews_locator))
+ def reviews(self):
+ return [self.DetailsReviewSnippet(self.testsetup, element)
+ for element in self.selenium.find_elements(*self._reviews_locator)]
@property
def version_info_link(self):
- return self.selenium.get_attribute("%s@href" % self._info_link_locator)
-
- @property
- def is_version_info_link_visible(self):
- return self.selenium.is_visible(self._info_link_locator)
+ return self.selenium.find_element(*self._info_link_locator).get_attribute('href')
def click_version_info_link(self):
- self.selenium.click(self._info_link_locator)
+ self.selenium.find_element(*self._info_link_locator).click()
def click_version_information_header(self):
- self.selenium.click("%s > a" % self._version_information_heading_locator)
+ self.selenium.find_element(*self._version_information_heading_link_locator).click()
def click_devs_comments_title(self):
- self.selenium.click("%s > h2 > a" % self._devs_comments_section_locator)
+ self.selenium.find_element(*self._devs_comments_title_locator).click()
class OtherAddons(Page):
- _other_addons_locator = 'css=#author-addons li'
- _name_locator = 'div.summary h3'
- _addon_link_locator = 'div.addon a'
- def __init__(self, testsetup, lookup):
- Page.__init__(self, testsetup)
- self.lookup = lookup
-
- def absolute_locator(self, relative_locator):
- return self._root_locator + relative_locator
+ _name_locator = (By.CSS_SELECTOR, 'div.summary h3')
+ _addon_link_locator = (By.CSS_SELECTOR, ' div.addon')
- @property
- def _root_locator(self):
- self.wait_for_element_visible(self._other_addons_locator)
- if type(self.lookup) == int:
- # lookup by index
- return "%s:nth(%s) " % (self._other_addons_locator, self.lookup)
- else:
- # lookup by name
- return "%s:contains(%s) " % (self._other_addons_locator, self.lookup)
+ def __init__(self, testsetup, element):
+ Page.__init__(self, testsetup)
+ self._root_element = element
@property
def name(self):
- self.selenium.mouse_over(self.absolute_locator(self._name_locator))
- return self.selenium.get_text(self.absolute_locator(self._name_locator))
+ return self._root_element.find_element(*self._name_locator).text
def click_addon_link(self):
- self.selenium.click(self.absolute_locator(self._addon_link_locator))
- self.selenium.wait_for_page_to_load(self.timeout)
-
- @property
- def name_link_value(self):
- return self.selenium.get_attribute('%s@href' % self.absolute_locator(self._name_link_locator))
+ self._root_element.find_element(*self._addon_link_locator).click()
+ #return Details(self.testsetup)
class DetailsReviewSnippet(Page):
- _reviews_locator = "css=#reviews div" # Base locator
- _username_locator = "p.byline a"
- _user_rating_locator = "span"
- _byline = ".byline"
- _details = ".description"
+ _reviews_locator = (By.CSS_SELECTOR, '#reviews div') # Base locator
+ _username_locator = (By.CSS_SELECTOR, 'p.byline a')
- def __init__(self, testsetup, lookup):
+ def __init__(self, testsetup, element):
Page.__init__(self, testsetup)
- self.lookup = lookup
-
- def absolute_locator(self, relative_locator):
- return self._root_locator + relative_locator
-
- @property
- def _root_locator(self):
- self.wait_for_element_visible(self._reviews_locator)
- if type(self.lookup) == int:
- # lookup by index
- return "%s:nth(%s) " % (self._reviews_locator, self.lookup)
- else:
- # lookup by name
- return "%s:contains(%s) " % (self._reviews_locator, self.lookup)
+ self._root_element = element
@property
def username(self):
- return self.selenium.get_text(self.absolute_locator(self._username_locator))
+ return self._root_element.find_element(*self._username_locator).text
def click_username(self):
- self.selenium.click(self.absolute_locator(self._username_locator))
- self.selenium.wait_for_page_to_load(self.timeout)
+ self._root_element.find_element(*self._username_locator).click()
from pages.user import User
return User(self.testsetup)
- @property
- def details(self):
- return self.selenium.get_text(self.absolute_locator(self._details))
-
- @property
- def byline(self):
- return self.selenium.get_text(self.absolute_locator(self._byline))
-
- @property
- def is_user_rating_visible(self):
- return self.selenium.is_visible(self.absolute_locator(self._user_rating_locator))
-
def click_to_write_review(self):
- self.selenium.click(self._add_review_link_locator)
+ self.selenium.find_element(*self._add_review_link_locator).click()
from pages.addons_site import WriteReviewBlock
return WriteReviewBlock(self.testsetup)
@property
def development_channel_text(self):
- return self.selenium.get_text('%s > h2' % self._development_channel_locator)
-
- @property
- def is_development_channel_header_visible(self):
- return self.selenium.is_visible('%s > h2' % self._development_channel_locator)
+ return self.selenium.find_element(*self._development_channel_title_locator).text
def click_development_channel(self):
- self.selenium.click('%s > h2 > a' % self._development_channel_locator)
+ self.selenium.find_element(*self._development_channel_title_locator).click()
@property
def is_development_channel_expanded(self):
- is_expanded = self.selenium.get_attribute("%s@class" % self._development_channel_locator)
+ is_expanded = self.selenium.find_element(*self._development_channel_locator).get_attribute('class')
return "expanded" in is_expanded
@property
def is_development_channel_content_visible(self):
- return self.selenium.is_visible('%s > div' % self._development_channel_locator)
-
- @property
- def is_developers_comments_content_visible(self):
- return self.selenium.is_visible('%s > div' % self._devs_comments_section_locator)
+ return self.is_element_visible(*self._development_channel_content_locator)
View
90 pages/discovery.py
@@ -45,117 +45,97 @@
#
# ***** END LICENSE BLOCK *****
+from selenium.webdriver.common.by import By
+
from pages.base import Base
class DiscoveryPane(Base):
- _what_are_addons_section_locator = 'id=intro'
- _what_are_addons_text_locator = 'css=#intro p'
- _mission_section_locator = 'id=mission'
- _mission_section_text_locator = 'css=#mission > p'
- _learn_more_locator = 'id=learn-more'
- _mozilla_org_link_locator = "css=#mission a"
- _download_count_text_locator = "id=download-count"
- _personas_section_locator = "id=featured-personas"
- _personas_see_all_link = "css=.all[href='/en-US/firefox/personas/']"
- _personas_locator = "//span[@class='addon-title']/b"
- _more_ways_section_locator = "id=more-ways"
- _more_ways_addons_locator = "id=more-addons"
- _more_ways_personas_locator = "id=more-personas"
- _up_and_coming_section = "id=up-and-coming"
- _up_and_coming_item = "//section[@id='up-and-coming']/ul/li/a[@class='addon-title']"
- _logout_link_locator = "css=#logout"
+ _what_are_addons_text_locator = (By.CSS_SELECTOR, '#intro p')
+ _mission_section_text_locator = (By.CSS_SELECTOR, '#mission > p')
+ _learn_more_locator = (By.ID, 'learn-more')
+ _mozilla_org_link_locator = (By.CSS_SELECTOR, "#mission a")
+ _download_count_text_locator = (By.ID, "download-count")
+ _personas_section_locator = (By.ID, "featured-personas")
+ _personas_see_all_link = (By.CSS_SELECTOR, ".all[href='/en-US/firefox/personas/']")
+ _personas_locator = (By.XPATH, "//span[@class='addon-title']/b")
+ _more_ways_section_locator = (By.ID, "more-ways")
+ _more_ways_addons_locator = (By.ID, "more-addons")
+ _more_ways_personas_locator = (By.ID, "more-personas")
+ _up_and_coming_item = (By.XPATH, "//section[@id='up-and-coming']/ul/li/a[@class='addon-title']")
+ _logout_link_locator = (By.CSS_SELECTOR, "#logout > a")
def __init__(self, testsetup, path):
Base.__init__(self, testsetup)
- self.selenium.open("%s/%s" % (self.site_version, path))
+ self.selenium.get("%s/%s" % (self.base_url, path))
#resizing this page for elements that disappear when the window is < 1000
- self.selenium.get_eval("window.resizeTo(10000,10000); window.moveTo(0,0)")
+ #self.selenium.set_window_size(1000, 1000) Commented because this selenium call is still in beta
@property
def what_are_addons_text(self):
- return self.selenium.get_text(self._what_are_addons_text_locator)
+ return self.selenium.find_element(*self._what_are_addons_text_locator).text
def click_learn_more(self):
- self.selenium.click(self._learn_more_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
-
- @property
- def is_mission_section_visible(self):
- return self.selenium.is_visible(self._mission_section_locator)
-
- def wait_for_mission_visible(self):
- self.wait_for_element_visible(self._mission_section_locator)
+ self.selenium.find_element(*self._learn_more_locator).click()
@property
def mission_section(self):
- return self.selenium.get_text(self._mission_section_text_locator)
+ return self.selenium.find_element(*self._mission_section_text_locator).text
def mozilla_org_link_visible(self):
- return self.selenium.is_visible(self._mozilla_org_link_locator)
+ return self.is_element_visible(*self._mozilla_org_link_locator)
@property
def download_count(self):
- self.wait_for_element_visible(self._download_count_text_locator)
- return self.selenium.get_text(self._download_count_text_locator)
+ return self.selenium.find_element(*self._download_count_text_locator).text
@property
def is_personas_section_visible(self):
- return self.selenium.is_visible(self._personas_section_locator)
+ return self.is_element_visible(*self._personas_section_locator)
@property
def personas_count(self):
- return int(self.selenium.get_xpath_count(self._personas_locator))
+ return len(self.selenium.find_elements(*self._personas_locator))
@property
def is_personas_see_all_link_visible(self):
- return self.selenium.is_visible(self._personas_see_all_link)
+ return self.is_element_visible(*self._personas_see_all_link)
@property
def first_persona(self):
- return self.selenium.get_text(self._personas_locator)
+ return self.selenium.find_elements(*self._personas_locator)[0].text
def click_on_first_persona(self):
- self.selenium.click(self._personas_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_elements(*self._personas_locator)[0].click()
return DiscoveryPersonasDetail(self.testsetup)
@property
def more_ways_section_visible(self):
- return self.selenium.is_visible(self._more_ways_section_locator)
+ return self.is_element_visible(*self._more_ways_section_locator)
@property
def more_ways_addons(self):
- return self.selenium.get_text(self._more_ways_addons_locator)
+ return self.selenium.find_element(*self._more_ways_addons_locator).text
@property
def more_ways_personas(self):
- return self.selenium.get_text(self._more_ways_personas_locator)
-
- @property
- def up_and_coming_visible(self):
- return self.selenium.is_visible(self._up_and_coming_section)
+ return self.selenium.find_element(*self._more_ways_personas_locator).text
@property
def up_and_coming_item_count(self):
- return int(self.selenium.get_xpath_count(self._up_and_coming_item))
-
- @property
- def is_logout_link_visible(self):
- return self.selenium.is_visible(self._logout_link_locator)
+ return len(self.selenium.find_elements(*self._up_and_coming_item))
def click_logout(self):
- self.selenium.click("%s > a" % self._logout_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._logout_link_locator).click()
from pages.home import Home
- return Home(self.testsetup)
+ return Home(self.testsetup, open_url=False)
class DiscoveryPersonasDetail(Base):
- _persona_title = 'css=h1.addon'
+ _persona_title = (By.CSS_SELECTOR, 'h1.addon')
@property
def persona_title(self):
- return self.selenium.get_text(self._persona_title)
+ return self.selenium.find_element(*self._persona_title).text
View
46 pages/extensions.py
@@ -21,6 +21,7 @@
# the Initial Developer. All Rights Reserved.
#
# Contributor(s): Bebe <florin.strugariu@softvision.ro>
+# Alin Trif <alin.trif@softvision.ro>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -36,42 +37,43 @@
#
# ***** END LICENSE BLOCK *****
+from selenium.webdriver.common.by import By
+
from pages.page import Page
from pages.base import Base
class ExtensionsHome(Base):
_page_title = 'Featured Extensions :: Add-ons for Firefox'
- _extensions_locator = "css=div.items div.item"
-
- @property
- def extension_count(self):
- return int(self.selenium.get_css_count(self._extensions_locator))
+ _extensions_locator = (By.CSS_SELECTOR, "div.items div.item")
+ _last_page_link_locator = (By.CSS_SELECTOR, ".paginator .rel > a:nth-child(4)")
+ _first_page_link_locator = (By.CSS_SELECTOR, ".paginator .rel > a:nth-child(1)")
@property
def extensions(self):
- return [self.Extension(self.testsetup, i) for i in range(self.extension_count)]
+ return [Extension(self.testsetup, element)
+ for element in self.selenium.find_elements(*self._extensions_locator)]
- class Extension(Page):
- _name_locator = " h3 a"
+ def go_to_last_page(self):
+ self.selenium.find_element(*self._last_page_link_locator).click()
- def __init__(self, testsetup, lookup):
- Page.__init__(self, testsetup)
- self.lookup = lookup
+ def go_to_first_page(self):
+ self.selenium.find_element(*self._first_page_link_locator).click()
- def absolute_locator(self, relative_locator):
- return self.root_locator + relative_locator
- @property
- def root_locator(self):
- if type(self.lookup) == int:
- # lookup by index
- return "css=div.items div.item:nth(%s)" % self.lookup
- else:
- # lookup by name
- return "css=div.items div.item:contains(%s)" % self.lookup
+class Extension(Page):
+ _name_locator = (By.CSS_SELECTOR, "h3 a")
+
+ def __init__(self, testsetup, element):
+ Page.__init__(self, testsetup)
+ self._root_element = element
@property
def name(self):
- return self.selenium.get_text(self.absolute_locator(self._name_locator))
+ return self._root_element.find_element(*self._name_locator).text
+
+ def click(self):
+ self._root_element.find_element(*self._name_locator).click()
+ from pages.details import Details
+ return Details(self.testsetup)
View
174 pages/home.py
@@ -45,216 +45,142 @@
#
# ***** END LICENSE BLOCK *****
+from selenium.webdriver.common.by import By
+
from pages.page import Page
from pages.base import Base
class Home(Base):
_page_title = "Add-ons for Firefox"
-
- _themes_link_locator = "css=#themes > a"
- _personas_link_locator = "css=#personas > a"
- _collections_link_locator = "css=#collections > a"
- _first_addon_locator = "css=div.summary > h3"
- _other_applications_link_locator = "id=other-apps"
+ _themes_link_locator = (By.CSS_SELECTOR, "#themes > a")
+ _personas_link_locator = (By.CSS_SELECTOR, "#personas > a")
+ _collections_link_locator = (By.CSS_SELECTOR, "#collections > a")
+ _first_addon_locator = (By.CSS_SELECTOR, "div.summary > a > h3")
+ _other_applications_link_locator = (By.ID, "other-apps")
#Most Popular List
- _most_popular_list_locator = "css=#homepage > .secondary"
- _most_popular_item_locator = "css=ol.toplist li"
- _most_popular_list_heading_locator = _most_popular_list_locator + " h2"
+ _most_popular_item_locator = (By.CSS_SELECTOR, "ol.toplist li")
+ _most_popular_list_heading_locator = (By.CSS_SELECTOR, "#homepage > .secondary h2")
- _explore_featured_link_locator = "css=#side-nav .s-featured a"
- _explore_most_popular_link_locator = "css=#side-nav .s-users a"
- _explore_most_top_rated_link_locator = "css=#side-nav .s-rating a"
+ _explore_featured_link_locator = (By.CSS_SELECTOR, "#side-nav .s-featured a")
+ _explore_most_popular_link_locator = (By.CSS_SELECTOR, "#side-nav .s-users a")
+ _explore_most_top_rated_link_locator = (By.CSS_SELECTOR, "#side-nav .s-rating a")
- _featured_personas_see_all_link = "css=#featured-personas h2 a"
- _featured_personas_locator = "id=featured-personas"
- _featured_personas_title_locator = "css=#featured-personas h2"
- _featured_personas_items_locator = "css=#featured-personas li"
+ _featured_personas_see_all_link = (By.CSS_SELECTOR, "#featured-personas h2 a")
+ _featured_personas_title_locator = (By.CSS_SELECTOR, "#featured-personas h2")
+ _featured_personas_items_locator = (By.CSS_SELECTOR, "#featured-personas li")
- _featured_collections_locator = "css=#featured-collections"
+ _category_list_locator = (By.CSS_SELECTOR, "ul#side-categories li")
- _category_list_locator = "css=ul#side-categories"
+ _extensions_menu_link = (By.CSS_SELECTOR, "#extensions > a")
- _extensions_menu_link = "css=#extensions > a"
-
- def __init__(self, testsetup):
+ def __init__(self, testsetup, open_url=True):
''' Creates a new instance of the class and gets the page ready for testing '''
Base.__init__(self, testsetup)
- self.selenium.open("%s/" % self.site_version)
- self.selenium.window_maximize()
+ if open_url:
+ self.selenium.get(self.base_url)
def click_featured_personas_see_all_link(self):
- self.selenium.click(self._featured_personas_see_all_link)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._featured_personas_see_all_link).click()
from pages.personas import Personas
return Personas(self.testsetup)
def click_personas(self):
- self.selenium.click(self._personas_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._personas_link_locator).click()
from pages.personas import Personas
return Personas(self.testsetup)
def click_themes(self):
- self.wait_for_element_visible(self._themes_link_locator)
- self.selenium.click(self._themes_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._themes_link_locator).click()
from pages.themes import Themes
return Themes(self.testsetup)
def click_collections(self):
- self.selenium.click(self._collections_link_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
- from pages.collection import Collections
- return Collections(self.testsetup)
-
- def click_featured_collections_see_all_link(self):
- self.selenium.click('%s h2 a' % self._featured_collections_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._collections_link_locator).click()
from pages.collection import Collections
return Collections(self.testsetup)
def click_extensions(self):
- self.selenium.click(self._extensions_menu_link)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._extensions_menu_link).click()
from pages.extensions import ExtensionsHome
return ExtensionsHome(self.testsetup)
def click_to_explore(self, what):
what = what.replace(' ', '_').lower()
- self.selenium.click(getattr(self, "_explore_most_%s_link_locator" % what))
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*getattr(self, "_explore_most_%s_link_locator" % what)).click()
from pages.extensions import ExtensionsHome
return ExtensionsHome(self.testsetup)
@property
def most_popular_count(self):
- return self.selenium.get_css_count(self._most_popular_item_locator)
-
- @property
- def is_most_popular_list_visible(self):
- return self.selenium.is_visible(self._most_popular_list_locator)
+ return len(self.selenium.find_elements(*self._most_popular_item_locator))
@property
def most_popular_list_heading(self):
- return self.selenium.get_text(self._most_popular_list_heading_locator)
-
- @property
- def is_featured_personas_visible(self):
- return self.selenium.is_visible(self._featured_personas_locator)
+ return self.selenium.find_element(*self._most_popular_list_heading_locator).text
@property
def featured_personas_count(self):
- return self.selenium.get_css_count(self._featured_personas_items_locator)
+ return len(self.selenium.find_elements(*self._featured_personas_items_locator))
@property
def featured_personas_title(self):
- return self.selenium.get_text(self._featured_personas_title_locator)
-
- @property
- def featured_collections_title(self):
- return self.selenium.get_text('%s h2' % self._featured_collections_locator)
-
- @property
- def featured_collections_visible_count(self):
- counter = 0
- for i in range(self.selenium.get_css_count('%s li' % self._featured_collections_locator)):
- if self.selenium.is_visible('%s li:nth(%s)' % (self._featured_collections_locator, i)):
- counter += 1
- return counter
+ return self.selenium.find_element(*self._featured_personas_title_locator).text
def click_on_first_addon(self):
- self.selenium.click(self._first_addon_locator)
- self.selenium.wait_for_page_to_load(self.timeout)
+ self.selenium.find_element(*self._first_addon_locator).click()
from pages.details import Details
return Details(self.testsetup)
def get_title_of_link(self, name):
name = name.lower().replace(" ", "_")
locator = getattr(self, "_%s_link_locator" % name)
- return self.selenium.get_attribute("%s@title" % locator)
+ return self.selenium.find_element(*locator).get_attribute('title')
@property
- def categories_count(self):
- return self.selenium.get_css_count("%s li" % self._category_list_locator)
-
def categories(self):
- return [self.Categories(self.testsetup, i) for i in range(self.categories_count)]
+ return [self.Categories(self.testsetup, element)
+ for element in self.selenium.find_elements(*self._category_list_locator)]
- def category(self, lookup):
- return self.Categories(self.testsetup, lookup)
-
- def most_popular_item(self, lookup):
- return self.MostPopularRegion(self.testsetup, lookup)
+ def category(self, element):
+ return self.Categories(self.testsetup, element)
@property
def most_popular_items(self):
- return [self.MostPopularRegion(self.testsetup, i) for i in range(self.most_popular_count)]
+ return [self.MostPopularRegion(self.testsetup, element)
+ for element in self.selenium.find_elements(*self._most_popular_item_locator)]
class Categories(Page):
- _categories_locator = 'css=#side-categories li'
- _link_locator = 'a'
+ _link_locator = (By.CSS_SELECTOR, 'a')
- def __init__(self, testsetup, lookup):
+ def __init__(self, testsetup, element):
Page.__init__(self, testsetup)
- self.lookup = lookup
-
- def absolute_locator(self, relative_locator=""):
- return self._root_locator + relative_locator
-
- @property
- def _root_locator(self):
- if type(self.lookup) == int:
- # lookup by index
- return "%s:nth(%s) " % (self._categories_locator, self.lookup)
- else:
- # lookup by name
- return "%s:contains(%s) " % (self._categories_locator, self.lookup)
+ self._root_element = element
@property
def name(self):
- return self.selenium.get_text(self.absolute_locator())
+ return self._root_element.text
def click_link(self):
- self.selenium.click(self.absolute_locator(self._link_locator))
- self.selenium.wait_for_page_to_load(self.timeout)
+ self._root_element.find_element(*self._link_locator).click()
from pages.category import Category
return Category(self.testsetup)
class MostPopularRegion(Page):
- _name_locator = " > span"
- _users_locator = " > small"
+ _name_locator = (By.TAG_NAME, "span")
+ _users_locator = (By.CSS_SELECTOR, "small")
- def __init__(self, testsetup, lookup):
+ def __init__(self, testsetup, element):
Page.__init__(self, testsetup)
- self.lookup = lookup
-
- def absolute_locator(self, relative_locator):
- return self.root_locator + relative_locator
-
- @property
- def root_locator(self):
- if type(self.lookup) == int:
- # lookup by index
- return "css=.toplist > li:nth(%s) > a" % self.lookup
- else:
- # lookup by name
- return "css=.toplist > li:contains(%s) > a" % self.lookup
+ self._root_element = element
@property
def name(self):
- return self.selenium.get_text(self.absolute_locator(self._name_locator))
-
- @property
- def users_text(self):
- return self.selenium.get_text(self.absolute_locator(self._users_locator))
+ self._root_element.find_element(*self._name_locator).text
@property
def users_number(self):
- number_str = self.users_text.split(' ')[0]
- number_str = number_str.replace(",", "")
- return int(number_str)
- from pages.category import Category
- return Category(self.testsetup)
+ users_text = self._root_element.find_element(*self._users_locator).text
+ return int(users_text.split(' ')[0].replace(',', ''))
View
94 pages/page.py
@@ -23,6 +23,7 @@
# Contributor(s): Vishal
# Dave Hunt <dhunt@mozilla.com>
# David Burns
+# Bebe
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@@ -41,8 +42,10 @@
Created on Jun 21, 2010
'''
-import re
-import time
+from unittestzero import Assert
+
+from selenium.common.exceptions import NoSuchElementException
+from selenium.common.exceptions import ElementNotVisibleException
class Page(object):
@@ -58,77 +61,32 @@ def __init__(self, testsetup):
self.base_url = testsetup.base_url
self.selenium = testsetup.selenium
self.timeout = testsetup.timeout
- self.site_version = testsetup.site_version
@property
def is_the_current_page(self):
- page_title = self.selenium.get_title()
- if not page_title == self._page_title:
- try:
- raise Exception("Expected page title to be: '"
- + self._page_title + "' but it was: '" + page_title + "'")
- except Exception:
- raise Exception('Expected page title does not match actual page title.')
- else:
- return True
+ Assert.equal(self.selenium.title, self._page_title,
+ "Expected page title: %s. Actual page title: %s" % (self._page_title, self.selenium.title))
+ return True