Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Migrate manage_cases, manage_products, manage_profiles pages.

  • Loading branch information...
commit 8b5b04adfcd0b9e56acef5b6bdc2b762f94a7bff 1 parent 714007b
Zac authored
View
38 pages/manage_cases_page.py
@@ -4,6 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from selenium.webdriver.common.by import By
+from selenium.webdriver.common.keys import Keys
from pages.base_page import MozTrapBasePage
@@ -11,35 +13,35 @@ class MozTrapManageCasesPage(MozTrapBasePage):
_page_title = 'MozTrap'
- _delete_case_locator = u'css=#managecases .itemlist .listitem[data-title="%(case_name)s"] .action-delete'
- _case_status_locator = u'css=#managecases .itemlist .listitem[data-title="%(case_name)s"] .status-action'
- _filter_input_locator = 'id=text-filter'
- _filter_suggestion_locator = u'css=#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]'
- _filter_locator = u'css=#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked'
+ _delete_case_locator = (By.CSS_SELECTOR, '#managecases .itemlist .listitem[data-title="%(case_name)s"] .action-delete')
+ _case_status_locator = (By.CSS_SELECTOR, '#managecases .itemlist .listitem[data-title="%(case_name)s"] .status-action')
+ _filter_input_locator = (By.ID, 'text-filter')
+ _filter_suggestion_locator = (By.CSS_SELECTOR, '#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]')
+ _filter_locator = (By.CSS_SELECTOR, '#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked')
def go_to_manage_cases_page(self):
- self.selenium.open('/manage/cases/')
+ self.selenium.get(self.base_url + '/manage/cases/')
self.is_the_current_page
def delete_case(self, name='Test Case'):
- _delete_locator = self._delete_case_locator % {'case_name': name}
+ _delete_locator = (self._delete_case_locator[0], self._delete_case_locator[1] % {'case_name': name})
- self.click(_delete_locator)
+ self.selenium.find_element(*_delete_locator).click()
self.wait_for_ajax()
def filter_cases_by_name(self, name):
- _filter_locator = self._filter_locator % {'filter_name': name.lower()}
- _filter_suggestion_locator = self._filter_suggestion_locator % {'filter_name': name}
-
- self.type(self._filter_input_locator, name)
- self.selenium.type_keys(self._filter_input_locator, name)
- self.wait_for_element_present(_filter_suggestion_locator)
- self.click(_filter_suggestion_locator)
- self.wait_for_element_present(_filter_locator)
+ '''
+ Types the name into the input field and then clicks the item in the search suggestions
+ '''
+ _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})
+
+ self.selenium.find_element(*self._filter_input_locator).send_keys(name)
+ self.selenium.find_element(*_filter_suggestion_locator).click()
self.wait_for_ajax()
def activate_case(self, name='Test Case'):
- _case_status_locator = self._case_status_locator % {'case_name': name}
+ _case_status_locator = (self._case_status_locator[0], self._case_status_locator[1] % {'case_name': name})
- self.click(_case_status_locator)
+ self.selenium.find_element(*_case_status_locator).click()
self.wait_for_ajax()
View
48 pages/manage_products_page.py
@@ -4,51 +4,49 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from selenium.webdriver.common.by import By
+from selenium.webdriver.common.keys import Keys
+
from pages.base_page import MozTrapBasePage
class MozTrapManageProductsPage(MozTrapBasePage):
_page_title = 'MozTrap'
- _delete_product_locator = u'css=#manageproducts .listitem .controls .action-delete[title="delete %(product_name)s"]'
- _filter_input_locator = 'id=text-filter'
- _filter_suggestion_locator = u'css=#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]'
- _filter_locator = u'css=#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked'
+ _delete_product_locator = (By.CSS_SELECTOR, '#manageproducts .listitem .controls .action-delete[title="delete %(product_name)s"]')
+ _filter_input_locator = (By.ID, 'text-filter')
+ _filter_suggestion_locator = (By.CSS_SELECTOR, '#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]')
+ _filter_locator = (By.CSS_SELECTOR, '#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked')
def go_to_manage_products_page(self):
- self.selenium.open('/manage/products/')
+ self.selenium.get(self.base_url + '/manage/products/')
self.is_the_current_page
def delete_product(self, name='Test Product'):
- _delete_locator = self._delete_product_locator % {'product_name': name}
+ _delete_locator = (self._delete_product_locator[0], self._delete_product_locator[1] % {'product_name': name})
- self.click(_delete_locator)
+ self.selenium.find_element(*_delete_locator).click()
self.wait_for_ajax()
def filter_products_by_name(self, name):
- _filter_locator = self._filter_locator % {'filter_name': name.lower()}
- _filter_suggestion_locator = self._filter_suggestion_locator % {'filter_name': name}
-
- self.type(self._filter_input_locator, name)
- self.selenium.type_keys(self._filter_input_locator, name)
- self.wait_for_element_present(_filter_suggestion_locator)
- self.click(_filter_suggestion_locator)
- self.wait_for_element_present(_filter_locator)
+ _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})
+
+ self.selenium.find_element(*self._filter_input_locator).send_keys(name)
+ self.selenium.find_element(*_filter_suggestion_locator).click()
self.wait_for_ajax()
def filter_products_by_name_without_mouse(self, name):
- _filter_locator = self._filter_locator % {'filter_name': name.lower()}
- _filter_suggestion_locator = self._filter_suggestion_locator % {'filter_name': name}
-
- self.type(self._filter_input_locator, name)
- self.selenium.type_keys(self._filter_input_locator, name)
- self.wait_for_element_present(_filter_suggestion_locator)
- self.selenium.key_down(self._filter_input_locator, '13')
- self.wait_for_element_present(_filter_locator)
+ _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_input_locator = self.selenium.find_element(*self._filter_input_locator)
+ filter_input_locator.send_keys(name)
+ filter_input_locator.send_keys(Keys.RETURN)
self.wait_for_ajax()
def remove_name_filter(self, name):
- _filter_locator = self._filter_locator % {'filter_name': name.lower()}
+ _filter_locator = (self._filter_locator[0], self._filter_locator[1] % {'filter_name': name.lower()})
- self.click(_filter_locator)
+ self.selenium.find_element(*_filter_locator).click()
self.wait_for_ajax()
View
33 pages/manage_profiles_page.py
@@ -4,6 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from selenium.webdriver.common.by import By
+
from pages.base_page import MozTrapBasePage
@@ -11,34 +13,31 @@ class MozTrapManageProfilesPage(MozTrapBasePage):
_page_title = 'MozTrap'
- _delete_profile_locator = u'css=#manageprofiles .listitem .action-delete[title="delete %(profile_name)s"]'
- _filter_input_locator = 'id=text-filter'
- _filter_suggestion_locator = u'css=#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]'
- _filter_locator = u'css=#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked'
+ _delete_profile_locator = (By.CSS_SELECTOR, '#manageprofiles .listitem .action-delete[title="delete %(profile_name)s"]')
+ _filter_input_locator = (By.ID, 'text-filter')
+ _filter_suggestion_locator = (By.CSS_SELECTOR, '#filter .textual .suggest .suggestion[data-type="name"][data-name="%(filter_name)s"]')
+ _filter_locator = (By.CSS_SELECTOR, '#filterform .filter-group input[data-name="name"][value="%(filter_name)s"]:checked')
def go_to_manage_profiles_page(self):
- self.open('/manage/profiles/')
+ self.selenium.get(self.base_url + '/manage/profiles/')
self.is_the_current_page
def delete_profile(self, name='Test Profile'):
- _delete_locator = self._delete_profile_locator % {'profile_name': name}
+ _delete_locator = (self._delete_profile_locator[0], self._delete_profile_locator[1] % {'profile_name': name})
- self.click(_delete_locator)
+ self.selenium.find_element(*_delete_locator).click()
self.wait_for_ajax()
def filter_profiles_by_name(self, name):
- _filter_locator = self._filter_locator % {'filter_name': name.lower()}
- _filter_suggestion_locator = self._filter_suggestion_locator % {'filter_name': name}
-
- self.type(self._filter_input_locator, name)
- self.selenium.type_keys(self._filter_input_locator, name)
- self.wait_for_element_present(_filter_suggestion_locator)
- self.click(_filter_suggestion_locator)
- self.wait_for_element_present(_filter_locator)
+ _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})
+
+ self.selenium.find_element(*self._filter_input_locator).send_keys(name)
+ self.selenium.find_element(*_filter_suggestion_locator).click()
self.wait_for_ajax()
def remove_name_filter(self, name):
- _filter_locator = self._filter_locator % {'filter_name': name.lower()}
+ _filter_locator = (self._filter_locator[0], self._filter_locator[1] % {'filter_name': name.lower()})
- self.click(_filter_locator)
+ self.selenium.find_element(*_filter_locator).click()
self.wait_for_ajax()
View
4 pages/page.py
@@ -58,3 +58,7 @@ def is_element_visible(self, *locator):
except NoSuchElementException, ElementNotVisibleException:
# this will return a snapshot, which takes time.
return False
+
+ def wait_for_ajax(self):
+ WebDriverWait(self.selenium, self.timeout).until(lambda s: s.execute_script("return $.active == 0"),
+ "Wait for AJAX timed out after %s seconds" % self.timeout)
Please sign in to comment.
Something went wrong with that request. Please try again.