Esempio n. 1
0
 def __init__(self):
     self.db = CustomerOperdb()
     self.op = OperationExcel('../../config/test_case.xlsx', '用例参数')
     self.autolog = Autolog()
     self.lp = LoginPage()
     self.lp.login(self.lp.op.get_cell(5, 2),
                   str(int(self.lp.op.get_cell(5, 3))))
Esempio n. 2
0
 def __init__(self):
     options=webdriver.ChromeOptions.headless
     self.ub = UseBrowser()
     self.op = OperationExcel('../../config/test_case.xlsx', '用例参数')
     self.bo = BrowserOperation(UseBrowser.driver)
     self.bo.open_url(self.op.get_cell(1,1))
     self.ya=YamlOperation('../../config/locator.yaml')
     self.autolog=Autolog()
Esempio n. 3
0
class LoginTest(unittest.TestCase):
    def setUp(self) -> None:

        self.l = LoginPage()
        self.autolog = Autolog()
        self.op = OperationExcel('../../config/test_case.xlsx', '用例参数')

    def test_login_name_psaawd_error(self):

        self.l.login(self.op.get_cell(1, 2), self.op.get_cell(1, 3))
        self.autolog.set_message('判断是否登录成功', 'info')
        self.assertEqual(self.l.login_False(), self.op.get_cell(1, 4))

    # def test_login_succes(self):
    #     self.l.login('admin','admin' )
    #     time.sleep(4)
    #     t=self.l.login_correct_text('main','/html/body/table/tbody/tr[1]/td/span')
    #     self.assertEqual(t, '欢迎使用报价管理系统')
    def test_login_passwd_error(self):
        self.l.login(self.op.get_cell(2, 2), self.op.get_cell(2, 3))
        self.autolog.set_message('判断是否登录成功', 'info')
        self.assertEqual(self.l.login_False(), self.op.get_cell(2, 4))
        # self.autolog.set_message('判断是否登录成功', 'info')

    def test_login_name_error(self):
        self.l.login(self.op.get_cell(3, 2), str(int(self.op.get_cell(3, 3))))
        self.autolog.set_message('判断是否登录成功', 'info')
        self.assertEqual(self.l.login_False(), self.op.get_cell(3, 4))
        # self.autolog.set_message('判断是否登录成功', 'info')

    def test_login_name_or_passwd_error(self):
        self.l.login(self.op.get_cell(4, 2), str(int(self.op.get_cell(4, 3))))
        self.autolog.set_message('判断是否登录成功', 'info')
        self.assertEqual(self.l.login_False(), self.op.get_cell(4, 4))
        # self.autolog.set_message('判断是否登录成功', 'info')

    def test_login_sucess(self):
        self.l.login(self.op.get_cell(5, 2), str(int(self.op.get_cell(5, 3))))
        t = self.l.login_correct_text(
            self.l.ya.get_data('CustomerPage', 'frametopFrame'),
            self.l.ya.get_data('LoginPage', 'succes'))
        # print(t)
        # print(self.op.get_cell(5, 4))
        self.autolog.set_message('判断是否登录成功', 'info')
        self.assertEqual(t, self.op.get_cell(5, 4))
        # self.autolog.set_message('判断是否登录成功', 'info')

    def tearDown(self) -> None:
        UseBrowser.quit()
Esempio n. 4
0
class LoginPage:

    def __init__(self):
        options=webdriver.ChromeOptions.headless
        self.ub = UseBrowser()
        self.op = OperationExcel('../../config/test_case.xlsx', '用例参数')
        self.bo = BrowserOperation(UseBrowser.driver)
        self.bo.open_url(self.op.get_cell(1,1))
        self.ya=YamlOperation('../../config/locator.yaml')
        self.autolog=Autolog()

    def login(self,username='',password=''):
        self.autolog.set_message('输入用户名','info')
        self.bo.send_keys(self.ya.get_data('LoginPage','username'),username)
        self.autolog.set_message('输入密码', 'info')
        self.bo.send_keys(self.ya.get_data('LoginPage','password'),password)
        self.autolog.set_message('点击登录', 'info')
        self.bo.click_element(self.ya.get_data('LoginPage','clicklogin'))

    def login_correct_text(self,frame_name,xpath):
        self.bo.change_frame(frame_name)#main
        return self.bo.get_text(xpath)#/html/body/table/tbody/tr[1]/td/span
    def login_False(self):
        alert=Alert(UseBrowser.driver)
        t=alert.text
        alert.accept()
        return t

# if __name__=='__main__':
#     l=LoginPage()
#     l.login('admin','123456')
#     time.sleep(4)
#     print(l.login_correct_text(l.ya.get_data('CustomerPage','frametopFrame'),l.ya.get_data('LoginPage','succes')))
#     print(l.op.get_cell(5, 4))
#     UseBrowser.quit()
Esempio n. 5
0
class CustomerTest(unittest.TestCase):
    def setUp(self) -> None:
        self.autolog = Autolog()
        self.c = CustomerPage()
        self.op = OperationExcel('../../config/test_case.xlsx', '用例参数')

    def test_customer_add(self):
        self.c.customer_add(name=self.op.get_cell(6, 5),
                            birthday=str(self.op.get_cell(6, 6)),
                            addman=self.op.get_cell(6, 7),
                            email=self.op.get_cell(6, 8))

        self.autolog.set_message('判断客户是否添加成功', 'info')
        self.assertEqual(self.c.login_False(), self.op.get_cell(6, 4))

    def test_customer_modify(self):
        self.c.customer_modify(str(int(self.op.get_cell(7, 9))))
        self.autolog.set_message('判断客户是否修改成功', 'info')
        self.assertEqual(self.c.login_False(), self.op.get_cell(7, 4))

    def tearDown(self) -> None:
        UseBrowser.quit()
Esempio n. 6
0
    def setUp(self) -> None:

        self.l = LoginPage()
        self.autolog = Autolog()
        self.op = OperationExcel('../../config/test_case.xlsx', '用例参数')
Esempio n. 7
0
class CustomerPage:
    def __init__(self):
        self.db = CustomerOperdb()
        self.op = OperationExcel('../../config/test_case.xlsx', '用例参数')
        self.autolog = Autolog()
        self.lp = LoginPage()
        self.lp.login(self.lp.op.get_cell(5, 2),
                      str(int(self.lp.op.get_cell(5, 3))))

    def customer_add(self, **kwargs):
        self.kwargs = kwargs
        # print(self.check_db_id_name())
        if self.check_db_id_name() == True:
            self.db.dele_customer(
                "delete from customer_info where customer_name='" +
                self.kwargs['name'] + "'")
        self.autolog.set_message('切换Frame', 'info')
        self.lp.bo.change_frame(
            self.lp.ya.get_data('CustomerPage', 'frametopFrame'))
        self.autolog.set_message('点击客户信息', 'info')
        self.lp.bo.click_element(
            self.lp.ya.get_data('CustomerPage', 'clickmation'))

        self.autolog.set_message('切换Frame', 'info')
        self.lp.bo.change_frame(
            self.lp.ya.get_data('CustomerPage', 'mainframe'))

        self.autolog.set_message('点击添加客户信息', 'info')
        self.lp.bo.click_element(
            self.lp.ya.get_data('CustomerPage', 'clickadd'))

        self.autolog.set_message('输入客户姓名', 'info')
        self.lp.bo.send_keys(
            self.lp.ya.get_data('CustomerPage', 'customername'),
            kwargs.get('name', ''))

        self.autolog.set_message('输入客户出生年月日', 'info')
        self.lp.bo.driver.execute_script(
            "window.document.getElementById('customerBirthday').value='" +
            str(kwargs.get('birthday', '')) + "'")

        self.autolog.set_message('输入客户创建人', 'info')
        self.lp.bo.send_keys(
            self.lp.ya.get_data('CustomerPage', 'customeraddman'),
            kwargs.get('addman', ''))

        self.autolog.set_message('输入客户email', 'info')
        self.lp.bo.send_keys(
            self.lp.ya.get_data('CustomerPage', 'customeremail'),
            kwargs.get('email', ''))
        time.sleep(4)

        self.autolog.set_message('点击添加', 'info')
        self.lp.bo.click_element(
            self.lp.ya.get_data('CustomerPage', 'clicksubmit'))

    def customer_modify(self, tel):
        self.autolog.set_message('切换Frame', 'info')
        self.lp.bo.change_frame(
            self.lp.ya.get_data('CustomerPage', 'frametopFrame'))
        time.sleep(1)
        self.autolog.set_message('点击客户信息', 'info')
        self.lp.bo.click_element(
            self.lp.ya.get_data('CustomerPage', 'clickmation'))

        self.autolog.set_message('切换Frame', 'info')
        self.lp.bo.change_frame(
            self.lp.ya.get_data('CustomerPage', 'mainframe'))

        self.autolog.set_message('点击编辑客户信息', 'info')
        self.lp.bo.click_element(
            self.lp.ya.get_data('CustomerPage', 'upcustmoer'))

        self.autolog.set_message('清空和输入客户手机号', 'info')
        self.lp.bo.clear_element(
            self.lp.ya.get_data('CustomerPage', 'customermobile'), tel)

        self.autolog.set_message('点击修改', 'info')
        self.lp.bo.click_element(
            self.lp.ya.get_data('CustomerPage', 'clicksubmit'))

    def check_db_id_name(self):
        page_content = []
        page_content.append(self.kwargs['name'])
        data = self.db.search_customer(
            "select * from customer_info where customer_name='" +
            self.kwargs['name'] + "'")
        if page_content == self.db.add_customer_dbata(data):
            return True
        return False

    def login_False(self):
        alert = Alert(UseBrowser.driver)
        t = alert.text
        alert.accept()
        return t