Permalink
Browse files

test for moztrap 5936. addresses #87

  • Loading branch information...
sashakruglov committed Jan 26, 2013
1 parent d91483b commit 9934bb7091812b14610137e5d70e1b01d8df9c32
View
@@ -73,6 +73,6 @@ def create_run(self, name='Test Run', product_version='Test Product Test Version
return run
@property
- def product_version(self):
+ def product_version_value(self):
product_version_select = Select(self.selenium.find_element(*self._product_version_select_locator))
return product_version_select.first_selected_option.text
@@ -41,3 +41,8 @@ def create_version(self, name='Test Version', product_name='Test Product'):
self.selenium.find_element(*self._submit_locator).click()
return version
+
+ @property
+ def product_name_value(self):
+ product_select = Select(self.selenium.find_element(*self._product_select_locator))
+ return product_select.first_selected_option.text
View
@@ -5,6 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from selenium.webdriver.common.by import By
+from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.color import Color
from pages.base_page import MozTrapBasePage
@@ -14,29 +15,25 @@ class MozTrapManageRunsPage(MozTrapBasePage):
_page_title = 'Manage-Runs'
- _create_run_locator = (By.CSS_SELECTOR, '#manageruns .create.single')
+ _create_run_button_locator = (By.CSS_SELECTOR, '#manageruns .create.single')
_delete_run_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .action-delete')
_run_activate_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .status-action.active')
_run_draft_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .status-action.draft')
_run_status_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .status-title')
_edit_run_locator = (By.CSS_SELECTOR, '#manageruns .itemlist .listitem[data-title="%(run_name)s"] .edit-link')
_filter_input_locator = (By.ID, 'text-filter')
- _filter_suggestion_by_name_locator = (By.CSS_SELECTOR,
- '#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]')
- _filter_suggestion_by_product_version_locator = (By.CSS_SELECTOR,
- '#filter .textual .suggest .suggestion[data-type="productversion"][data-name="%(filter_name)s"]')
- _filter_locator = (By.CSS_SELECTOR,
- '#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked')
- _pin_filter_button_locator = (By.CSS_SELECTOR,
- '#filterform input[data-name="productversion"]:checked + .onoff .pinswitch')
+ _filter_suggestion_by_name_locator = (By.CSS_SELECTOR, '#filter .suggestion[data-type="name"][data-name="%(filter_name)s"]')
+ _filter_suggestion_by_product_version_locator = (By.CSS_SELECTOR, '#filter .suggestion[data-type="productversion"][data-name="%(filter_name)s"]')
+ _filter_locator = (By.CSS_SELECTOR, '#filterform input[data-name="name"][value="%(filter_name)s"]:checked')
+ _pin_filter_button_locator = (By.CSS_SELECTOR, '#filterform input[data-name="productversion"]:checked + .onoff .pinswitch')
_pinned_filter_locator = (By.CSS_SELECTOR, '#filterform .onoff.pinned')
def go_to_manage_runs_page(self):
self.selenium.get(self.base_url + '/manage/runs/')
self.is_the_current_page
def click_create_run_button(self):
- self.selenium.find_element(*self._create_run_locator).click()
+ self.selenium.find_element(*self._create_run_button_locator).click()
from pages.create_run_page import MozTrapCreateRunPage
return MozTrapCreateRunPage(self.testsetup)
@@ -52,6 +49,7 @@ def filter_runs_by_name(self, name):
self._filter_suggestion_by_name_locator[1] % {'filter_name': name})
self.selenium.find_element(*self._filter_input_locator).send_keys(name)
+ WebDriverWait(self.selenium, self.timeout).until(lambda s: self.is_element_visible(*_filter_suggestion_locator))
self.selenium.find_element(*_filter_suggestion_locator).click()
self.wait_for_ajax()
@@ -61,6 +59,7 @@ def filter_runs_by_product_version(self, product_version):
self._filter_suggestion_by_product_version_locator[1] % {'filter_name': product_version})
self.selenium.find_element(*self._filter_input_locator).send_keys(product_version)
+ WebDriverWait(self.selenium, self.timeout).until(lambda s: self.is_element_visible(*_filter_suggestion_locator))
self.selenium.find_element(*_filter_suggestion_locator).click()
self.wait_for_ajax()
@@ -95,11 +94,10 @@ def go_to_edit_run_page(self, name='Test Run'):
from pages.edit_run_page import MozTrapEditRunPage
return MozTrapEditRunPage(self.testsetup)
- def pin_product_version(self):
+ def pin_filter_by_product_version(self):
self.selenium.find_element(*self._pin_filter_button_locator).click()
- @property
- def pinned_filter_color(self, coding='hex'):
+ def get_pinned_filter_color(self, coding='hex'):
pinned_filter = self.selenium.find_element(*self._pinned_filter_locator)
color = pinned_filter.value_of_css_property('background-color')
- return getattr(Color.from_string(color), coding)
+ return getattr(Color.from_string(color), coding).upper()
@@ -6,6 +6,7 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
+from selenium.webdriver.support.color import Color
from pages.base_page import MozTrapBasePage
@@ -16,32 +17,63 @@ class MozTrapManageVersionsPage(MozTrapBasePage):
_version_manage_locator = (By.CSS_SELECTOR, '#manageproductversions .listitem .title[title="%(product_name)s %(version_name)s"]')
_version_homepage_locator = (By.CSS_SELECTOR, '.runsdrill .runsfinder .productversions .colcontent .title[title="%(version_name)s"][data-product="%(product_name)s"])')
+ _create_version_button_locator = (By.CSS_SELECTOR, '#manageproductversions .create.single')
_delete_version_locator = (By.CSS_SELECTOR, '#manageproductversions .listitem .action-delete[title="delete %(product_name)s %(version_name)s"]')
_clone_version_locator = (By.CSS_SELECTOR, '#manageproductversions .listitem .action-clone[title="clone %(product_name)s %(version_name)s"]')
_filter_input_locator = (By.ID, 'text-filter')
- _filter_suggestion_locator = (By.CSS_SELECTOR, '#filter .textual .suggest .suggestion[data-type="version"][data-name="%(filter_name)s"]')
- _filter_locator = (By.CSS_SELECTOR, '#filterform .filter-group input[data-name="version"][value="%(filter_name)s"]:checked + span label')
+ _filter_suggestion_locator = (By.CSS_SELECTOR, '#filter .suggestion[data-type="%(filter_lookup)s"][data-name="%(filter_name)s"]')
+ _filter_locator = (By.CSS_SELECTOR, '#filterform input[data-name="%(filter_lookup)s"][value="%(filter_name)s"]:checked + span label')
+ _pin_filter_button_locator = (By.CSS_SELECTOR, '#filterform input[data-name="%(filter_lookup)s"]:checked + .onoff .pinswitch')
+ _pinned_filter_locator = (By.CSS_SELECTOR, '#filterform .onoff.pinned')
def go_to_manage_versions_page(self):
self.get_relative_path('/manage/productversions/')
self.is_the_current_page
+ def click_create_version_button(self):
+ self.selenium.find_element(*self._create_version_button_locator).click()
+ from pages.create_version_page import MozTrapCreateVersionPage
+ return MozTrapCreateVersionPage(self.testsetup)
+
def delete_version(self, name='Test Version', product_name='Test Product'):
_delete_locator = (self._delete_version_locator[0], self._delete_version_locator[1] % {'product_name': product_name, 'version_name': name})
self.selenium.find_element(*_delete_locator).click()
self.wait_for_ajax()
def filter_versions_by_name(self, name):
- _filter_locator = (self._filter_locator[0], self._filter_locator[1] % {'filter_name': name.lower()})
- _filter_suggestion_locator = (self._filter_suggestion_locator[0], self._filter_suggestion_locator[1] % {'filter_name': name})
+ _filter_locator = (
+ self._filter_locator[0],
+ self._filter_locator[1] % {'filter_lookup': 'version', 'filter_name': name.lower()})
+ _filter_suggestion_locator = (
+ self._filter_suggestion_locator[0],
+ self._filter_suggestion_locator[1] % {'filter_lookup': 'version', 'filter_name': name})
self.selenium.find_element(*self._filter_input_locator).send_keys(name)
WebDriverWait(self.selenium, self.timeout).until(lambda s: self.is_element_visible(*_filter_suggestion_locator))
self.selenium.find_element(*_filter_suggestion_locator).click()
WebDriverWait(self.selenium, self.timeout).until(lambda s: self.is_element_visible(*_filter_locator))
self.wait_for_ajax()
+ def filter_versions_by_product(self, product_name):
+ _filter_suggestion_locator = (
+ self._filter_suggestion_locator[0],
+ self._filter_suggestion_locator[1] % {'filter_lookup': 'product', 'filter_name': product_name})
+
+ self.selenium.find_element(*self._filter_input_locator).send_keys(product_name)
+ WebDriverWait(self.selenium, self.timeout).until(lambda s: self.is_element_visible(*_filter_suggestion_locator))
+
+ suggestion = self.selenium.find_element(*_filter_suggestion_locator)
+ data_id = suggestion.get_attribute('data-id')
+ suggestion.click()
+
+ _filter_locator = (
+ self._filter_locator[0],
+ self._filter_locator[1] % {'filter_lookup': 'product', 'filter_name': data_id.lower()})
+
+ WebDriverWait(self.selenium, self.timeout).until(lambda s: self.is_element_visible(*_filter_locator))
+ self.wait_for_ajax()
+
def remove_name_filter(self, name):
_filter_locator = (self._filter_locator[0], self._filter_locator[1] % {'filter_name': name.lower()})
@@ -61,3 +93,14 @@ def clone_version(self, name='Test Version', product_name='Test Product'):
cloned_version['homepage_locator'] = (self._version_homepage_locator[0], self._version_homepage_locator[1] % {'product_name': cloned_version['product_name'], 'version_name': cloned_version['name']})
return cloned_version
+
+ def pin_filter_by_product(self):
+ _pin_filter_button_locator = (
+ self._pin_filter_button_locator[0],
+ self._pin_filter_button_locator[1] % {'filter_lookup': 'product'})
+ self.selenium.find_element(*_pin_filter_button_locator).click()
+
+ def get_pinned_filter_color(self, coding='hex'):
+ pinned_filter = self.selenium.find_element(*self._pinned_filter_locator)
+ color = pinned_filter.value_of_css_property('background-color')
+ return getattr(Color.from_string(color), coding).upper()
@@ -9,7 +9,9 @@
from unittestzero import Assert
from pages.base_test import BaseTest
-from pages.manage_runs_page import MozTrapManageRunsPage
+
+
+PINNED_FILTER_COLOR = u'#DFB081'
class TestPinningFilters(BaseTest):
@@ -20,17 +22,43 @@ def test_that_pinning_filter_on_product_version_set_defaults_in_new_run(self, mo
product = self.create_product(mozwebqa_logged_in)
product_version = u'%s %s' % (product['name'], product['version']['name'])
+ from pages.manage_runs_page import MozTrapManageRunsPage
manage_runs_pg = MozTrapManageRunsPage(mozwebqa_logged_in)
manage_runs_pg.go_to_manage_runs_page()
manage_runs_pg.filter_runs_by_product_version(product_version)
- manage_runs_pg.pin_product_version()
+ manage_runs_pg.pin_filter_by_product_version()
Assert.equal(
- manage_runs_pg.pinned_filter_color.upper(),
- u'#DFB081')
+ manage_runs_pg.get_pinned_filter_color(),
+ PINNED_FILTER_COLOR,
+ u'pinned filter\'s color is not orange')
create_run_pg = manage_runs_pg.click_create_run_button()
Assert.equal(
- create_run_pg.product_version,
- product_version)
+ create_run_pg.product_version_value,
+ product_version,
+ u'default product version is incorrect')
+
+ @pytest.mark.moztrap(5936)
+ @pytest.mark.nondestructive
+ def test_that_pinning_filter_on_product_sets_defaults_in_new_product_version(self, mozwebqa_logged_in):
+ product = self.create_product(mozwebqa_logged_in)
+
+ from pages.manage_versions_page import MozTrapManageVersionsPage
+ manage_versions_pg = MozTrapManageVersionsPage(mozwebqa_logged_in)
+ manage_versions_pg.go_to_manage_versions_page()
+ manage_versions_pg.filter_versions_by_product(product['name'])
+ manage_versions_pg.pin_filter_by_product()
+
+ Assert.equal(
+ manage_versions_pg.get_pinned_filter_color(),
+ PINNED_FILTER_COLOR,
+ u'pinned filter\'s color is not orange')
+
+ create_version_pg = manage_versions_pg.click_create_version_button()
+
+ Assert.equal(
+ create_version_pg.product_name_value,
+ product['name'],
+ u'default product is incorrect')

0 comments on commit 9934bb7

Please sign in to comment.