Migrate base_page and create_case_page
This commit is contained in:
Родитель
3b7b669692
Коммит
cbd9381667
|
@ -1,3 +1,3 @@
|
|||
[DEFAULT]
|
||||
baseurl = http://caseconductor-dev.allizom.org
|
||||
baseurl = http://moztrap-dev.allizom.org
|
||||
tags = moztrap-tests
|
|
@ -4,23 +4,33 @@
|
|||
# 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.page import Page
|
||||
|
||||
|
||||
class MozTrapBasePage(Page):
|
||||
|
||||
_user_name_locator = 'css=#accountnav .account-welcome .fn'
|
||||
_logout_locator = 'css=#accountnav .account-links .signout'
|
||||
_user_name_locator = (By.CSS_SELECTOR, '#accountnav .account-welcome .fn')
|
||||
_logout_locator = (By.CSS_SELECTOR, '#accountnav .account-links .signout')
|
||||
|
||||
@property
|
||||
def is_user_logged_in(self):
|
||||
return self.is_element_visible(self._logout_locator)
|
||||
return self.is_element_visible(*self._logout_locator)
|
||||
|
||||
@property
|
||||
def users_name_text(self):
|
||||
return self.get_text(self._user_name_locator)
|
||||
return self.selenium.find_element(*self._user_name_locator).text
|
||||
|
||||
def logout(self):
|
||||
self.click(self._logout_locator, True)
|
||||
self.selenium.find_element(*self._logout_locator).click()
|
||||
from login_page import MozTrapLoginPage
|
||||
return MozTrapLoginPage(self.testsetup)
|
||||
|
||||
@property
|
||||
def header(self):
|
||||
return self.Header(testsetup)
|
||||
|
||||
class Header(Page):
|
||||
|
||||
pass
|
|
@ -4,27 +4,30 @@
|
|||
# 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 pages.base_page import MozTrapBasePage
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.select import Select
|
||||
from datetime import datetime
|
||||
|
||||
from pages.base_page import MozTrapBasePage
|
||||
|
||||
|
||||
class MozTrapCreateCasePage(MozTrapBasePage):
|
||||
|
||||
_page_title = 'MozTrap'
|
||||
|
||||
_name_locator = 'id=id_name'
|
||||
_product_select_locator = 'id=id_product'
|
||||
_version_select_locator = 'id=id_productversion'
|
||||
_suite_select_locator = 'id=id_initial_suite'
|
||||
_description_locator = 'id=id_description'
|
||||
_step1_instruction_locator = 'id=id_steps-0-instruction'
|
||||
_step1_result_locator = 'id=id_steps-0-expected'
|
||||
_status_select_locator = 'id=id_status'
|
||||
_submit_locator = 'css=#single-case-add .form-actions button[type="submit"]'
|
||||
_case_locator = u'css=#managecases .itemlist .listitem .title[title="%(case_name)s"]'
|
||||
_name_locator = (By.ID, 'id_name')
|
||||
_product_select_locator = (By.ID, 'id_product')
|
||||
_version_select_locator = (By.ID, 'id_productversion')
|
||||
_suite_select_locator = (By.ID, 'id_initial_suite')
|
||||
_description_locator = (By.ID, 'id_description')
|
||||
_step1_instruction_locator = (By.ID, 'id_steps-0-instruction')
|
||||
_step1_result_locator = (By.ID, 'id_steps-0-expected')
|
||||
_status_select_locator = (By.ID, 'id_status')
|
||||
_submit_locator = (By.CSS_SELECTOR, '#single-case-add .form-actions button[type="submit"]')
|
||||
_case_locator = (By.CSS_SELECTOR, 'css=#managecases .itemlist .listitem .title[title="%(case_name)s"]')
|
||||
|
||||
def go_to_create_case_page(self):
|
||||
self.selenium.open('/manage/case/add/')
|
||||
self.selenium.get(self.base_url + '/manage/case/add/')
|
||||
self.is_the_current_page
|
||||
|
||||
def create_case(self, name='Test Case', product='Test Product', version='Test Version', suite=None, desc='This is a test case', step1_instruction='Test Case step 1 instruction', step1_result='Test Case step 1 expected result', status='active'):
|
||||
|
@ -32,17 +35,28 @@ class MozTrapCreateCasePage(MozTrapBasePage):
|
|||
case = {}
|
||||
case['name'] = u'%(name)s %(dt_string)s' % {'name': name, 'dt_string': dt_string}
|
||||
case['desc'] = u'%(desc)s created on %(dt_string)s' % {'desc': desc, 'dt_string': dt_string}
|
||||
case['locator'] = self._case_locator % {'case_name': case['name']}
|
||||
case['locator'] = (self._case_locator[0], self._case_locator[1] % {'case_name': case['name']})
|
||||
|
||||
name_field = self.selenium.find_element(*self._name_locator)
|
||||
name_field.send_keys(case['name'])
|
||||
|
||||
product_select = Select(self.selenium.find_element(*self._product_select_locator))
|
||||
product_select.select_by_visible_text(product)
|
||||
|
||||
version_select = Select(self.selenium.find_element(*self._version_select_locator))
|
||||
version_select.select_by_visible_text(product)
|
||||
|
||||
self.type(self._name_locator, case['name'])
|
||||
self.select(self._product_select_locator, product)
|
||||
self.select(self._version_select_locator, version)
|
||||
if suite:
|
||||
self.select(self._suite_select_locator, suite)
|
||||
self.type(self._description_locator, case['desc'])
|
||||
self.type(self._step1_instruction_locator, step1_instruction)
|
||||
self.type(self._step1_result_locator, step1_result)
|
||||
self.select(self._status_select_locator, status)
|
||||
self.click(self._submit_locator, wait_flag=True)
|
||||
suite_select = Select(self.selenium.find_element(*self._suite_select_locator))
|
||||
suite_select.select_by_visible_text(suite)
|
||||
|
||||
self.selenium.find_element(*self._description_locator).send_keys(case['desc'])
|
||||
self.selenium.find_element(*self._step1_instruction_locator).send_keys(step1_instruction)
|
||||
self.selenium.find_element(*self._step1_result_locator).send_keys(step1_result)
|
||||
|
||||
status_select = Select(self.find_element(By.CSS_SELECTOR, *self._status_select_locator))
|
||||
status_select.select_by_visible_text(status)
|
||||
|
||||
self.selenium.find_element(*self._submit_locator).click()
|
||||
|
||||
return case
|
||||
|
|
Загрузка…
Ссылка в новой задаче