Exemple #1
0
 def __init__(self):
     self.op = OperationExcel('../../config/test_case.xlsx', '登录用例参数')
     self.ub = UseBrowser()
     self.bo = Browseroperation(UseBrowser.driver)
     self.yaml = YamlOperation('../../config/locator.yaml')
     self.bo.open_url(self.op.get_cell(1, 1))
     self.log = Crm_log()
Exemple #2
0
class LoginPage:
    def __init__(self):
        self.op = OperationExcel('../../config/test_case.xlsx', '登录用例参数')
        self.ub = UseBrowser()
        self.bo = Browseroperation(UseBrowser.driver)
        self.yaml = YamlOperation('../../config/locator.yaml')
        self.bo.open_url(self.op.get_cell(1, 1))
        self.log = Crm_log()

    def login(self, username='', password=''):
        self.log.set_message('-' * 5 + '登录功能开始', 'info')
        self.bo.send_keys(self.yaml.get_locator('LoginPage', 'username'),
                          username)
        self.log.set_message('-' * 5 + '输入用户名:' + username, 'info')
        self.bo.send_keys(self.yaml.get_locator('LoginPage', 'password'),
                          password)
        self.log.set_message('-' * 5 + '输入密码:' + password, 'info')
        self.bo.click_element(
            self.yaml.get_locator('LoginPage', 'submit_button'))
        self.log.set_message('-' * 5 + '点击登录', 'info')
        time.sleep(2)

    def get_alert_text(self):
        return Alert(UseBrowser.driver).text

    def get_page_title(self):
        return UseBrowser.driver.title

    def login_correct_text(self, frame_name, xpath):
        self.bo.change_frame(frame_name)
        return self.bo.get_text(xpath)
Exemple #3
0
class CustomerAllocate:
    def __init__(self):
        self.op = OperationExcel('../../config/test_case.xlsx', '登录用例参数')
        self.yaml = YamlOperation('../../config/locator.yaml')
        self.lp = LoginPage()
        self.lp.login(self.op.get_cell(2, 2), self.op.get_cell(2, 3))
        self.log = Crm_log()

    def allocate_customer(self):
        self.log.set_message('change frame', 'info')
        self.lp.bo.change_frame('/html/frameset/frameset/frame[1]')
        self.log.set_message('click button:客户分配', 'info')
        self.lp.bo.click_element('//*[@id="submenu1"]/div/table/tbody/tr[1]/td/table/tbody/tr[2]/td[2]/table/tbody/tr/td/span/a')
        self.lp.bo.change_frame('mainFrame')
        self.log.set_message('click button:分配', 'info')
        self.lp.bo.click_element('/html/body/form/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[10]/td[9]/div/span/a')
        self.log.set_message('click button:提交', 'info')
        self.lp.bo.click_element('/html/body/form/table[2]/tbody/tr/td[2]/input')
Exemple #4
0
 def setUp(self) -> None:
     self.op = OperationExcel('../../config/test_case.xlsx', '登录用例参数')
     self.ca = CustomerAllocate()
     self.bo = Browseroperation(UseBrowser.driver)
     self.dbop = CustomerOprationDb()
Exemple #5
0
 def __init__(self):
     self.op = OperationExcel('../../config/test_case.xlsx', '登录用例参数')
     self.yaml = YamlOperation('../../config/locator.yaml')
     self.lp = LoginPage()
     self.lp.login(self.op.get_cell(2, 2), self.op.get_cell(2, 3))
     self.log = Crm_log()
Exemple #6
0
 def setUp(self) -> None:
     self.op = OperationExcel('../../config/test_case.xlsx', '登录用例参数')
     self.login = LoginPage()
     self.bo = Browseroperation(UseBrowser.driver)
Exemple #7
0
class LoginTest(unittest.TestCase):
    def setUp(self) -> None:
        self.op = OperationExcel('../../config/test_case.xlsx', '登录用例参数')
        self.login = LoginPage()
        self.bo = Browseroperation(UseBrowser.driver)

    def test_login_username_password_null(self):
        self.login.login(self.op.get_cell(1, 2), self.op.get_cell(1, 3))
        alert = self.bo.get_alert_text()
        self.assertEqual(alert, self.op.get_cell(1, 4))

    def test_login_success(self):
        self.login.login(self.op.get_cell(2, 2), self.op.get_cell(2, 3))
        test = self.login.get_page_title()
        self.assertEqual(test, self.op.get_cell(2, 4))

    def test_login_error(self):
        self.login.login(self.op.get_cell(3, 2), self.op.get_cell(3, 3))
        test = self.login.get_alert_text()
        self.assertEqual(test, self.op.get_cell(3, 4))

    def test_login_username_null(self):
        self.login.login(self.op.get_cell(4, 2), self.op.get_cell(4, 3))
        test = self.login.get_alert_text()
        self.assertEqual(test, self.op.get_cell(4, 4))

    def test_login_pwd_null(self):
        self.login.login(self.op.get_cell(5, 2), self.op.get_cell(5, 3))
        test = self.login.get_alert_text()
        self.assertEqual(test, self.op.get_cell(5, 4))

    def tearDown(self) -> None:
        UseBrowser.quit()