Beispiel #1
0
 def query_customer(self, base_config_path, query_customer_data):
     driver = self.driver
     Service.miss_login(driver, base_config_path)
     driver.find_element_by_link_text('会员管理').click()
     self.input_phone(query_customer_data['customerphone'])
     driver.find_element_by_css_selector(
         'button.form-control:nth-child(3)').click()
Beispiel #2
0
    def do_login(self, base_config_path, login_data):

        Service.open_page(self.driver, base_config_path)
        self.input_uname(login_data['username'])
        self.input_upass(login_data['password'])
        self.input_vfcode(login_data['verifycode'])
        self.click_button()
Beispiel #3
0
 def add_customer(self, base_config_path, add_customer_data):
     driver = self.driver
     Service.miss_login(driver, base_config_path)
     driver.find_element_by_link_text('会员管理').click()
     self.input_phone(add_customer_data['customerphone'])
     self.input_name(add_customer_data['customername'])
     self.select_sex()
     self.input_date(add_customer_data['childdate'])
     self.input_creditkids(add_customer_data['creditkids'])
     self.input_creditcloth(add_customer_data['creditcloth'])
     self.click_add_button()
Beispiel #4
0
    def test_add_customer(self,cname,cphone,cdata,ckids,ccloth,expect):
        add_customer_data={'customername':cname,'customerphone':cphone,
                           'childdate':cdata,'creditkids':ckids,
                           'creditcloth':ccloth}

        sql='select count(customerid) from customer'
        old_customer_count=Utility.query_one('..\\config\\base.conf',sql)
        self.customer.add_customer('..\\config\\base.conf',add_customer_data)

        if Service.is_element_present(self.driver, By.CSS_SELECTOR,
                                      '.modal-sm > div:nth-child(1) > div:nth-child(3) > button:nth-child(1)'):
            time.sleep(2)
            # 用于获取弹出页面的文本内容
            content = self.driver.find_element_by_css_selector('.bootbox-body').text
            if '请勿重复添加' in content:
                actual = 'already-added'
            else:
                actual = 'add-failed'
        else:
            # 判断customer表中的记录数是否增加
            new_customer_count = Utility.query_one('..\\config\\base.conf', sql)
            if new_customer_count[0] - old_customer_count[0] == 1:
                actual = 'add-successful'
            else:
                actual = 'add-failed'

        self.assertEqual(actual,expect)
    def test_scan_barcode(self, barcode, expect):

        self.sales.scan_barcode(barcode)
        time.sleep(2)
        if Service.is_element_present(self.driver, By.LINK_TEXT, '移除'):
            actual = 'scan_successful'
        else:
            actual = 'scan_fail'
        self.assertEqual(actual, expect)
Beispiel #6
0
 def edit_customer(self, base_config_path, edit_customer_data):
     # 1.登录;2.打开会员管理页面;3.输入电话号码(为空),点击查询;4.找到刚才定义的元素
     Service.miss_login(self.driver, base_config_path)
     self.driver.find_element_by_link_text('会员管理').click()
     self.click_query_button()
     # 编写sql,查询符合条件的记录数
     sql = 'select count(customerid) from customer'
     from guitest.woniusales_test02.util.utility import Utility
     customer_count = Utility.query_one(base_config_path, sql)[0]
     self.get_random_edit_ele(customer_count)
     # 将要修改的数据重新填入
     self.input_phone(edit_customer_data['customerphone'])
     self.input_name(edit_customer_data['customername'])
     self.select_sex()
     self.input_date(edit_customer_data['childdate'])
     self.input_creditkids(edit_customer_data['creditkids'])
     self.input_creditcloth(edit_customer_data['creditcloth'])
     self.click_edit()
Beispiel #7
0
    def test_login(self, uname, upass, vfcode, expect):

        login_data = {
            'username': uname,
            'password': upass,
            'verifycode': vfcode
        }
        self.login.do_login('..\\config\\base.conf', login_data)
        from selenium.webdriver.common.by import By
        if Service.is_element_present(self.driver, By.LINK_TEXT, '注销'):
            actual = 'login-pass'
            self.driver.find_element_by_link_text('注销').click()
        else:
            actual = 'login-fail'
            self.driver.refresh()
        self.assertEqual(actual, expect)
Beispiel #8
0
 def setUpClass(cls):
     cls.driver = Service.get_driver('..\\config\\base.conf')
     cls.login = Login(cls.driver)
Beispiel #9
0
 def input_upass(self, password):
     upass = self.driver.find_element_by_id('password')
     Service.send_input(upass, password)
Beispiel #10
0
 def input_date(self, childdate):
     Service.remove_readonly(self.driver, 'childdate')
     childdate_ele = self.driver.find_element_by_id('childdate')
     Service.send_input(childdate_ele, childdate)
Beispiel #11
0
 def select_sex(self):
     sex_select = self.driver.find_element_by_id('childsex')
     Service.select_random(sex_select)
Beispiel #12
0
 def input_name(self, customername):
     cname = self.driver.find_element_by_id('customername')
     Service.send_input(cname, customername)
Beispiel #13
0
 def input_phone(self, customerphone):
     phone = self.driver.find_element_by_id('customerphone')
     Service.send_input(phone, customerphone)
Beispiel #14
0
 def input_vfcode(self, verifycode):
     vfcode = self.driver.find_element_by_id('verifycode')
     Service.send_input(vfcode, verifycode)
Beispiel #15
0
 def input_creditkids(self, creditkids):
     kids = self.driver.find_element_by_id('creditkids')
     Service.send_input(kids, creditkids)
Beispiel #16
0
 def setUp(self):
     self.driver = Service.get_driver('..\\config\\base.conf')
     from guitest.woniusales_test03.common.customer import Customer
     self.customer=Customer(self.driver)
Beispiel #17
0
 def input_creditcloth(self, creditcloth):
     cloth = self.driver.find_element_by_id('creditcloth')
     Service.send_input(cloth, creditcloth)
Beispiel #18
0
 def setUp(self):
     self.driver = Service.get_driver('..\\config\\base.conf')
     from guitest.woniusales_test03.common.sales import Sales
     self.sales=Sales(self.driver,'..\\config\\base.conf')
Beispiel #19
0
 def input_uname(self, username):
     uname = self.driver.find_element_by_id('username')
     Service.send_input(uname, username)