def test_person_submit_ok(self): # 个人点击提交 """ 这里一定要test开头,把测试逻辑代码封装到一个test开头的方法里。 :return: """ sn = 'T203193B40683' orderSn = BasePage.random_32(1) amount = 0.01 shopOrderSn = BasePage.random_32(3) Url = "http://api.sunmi.com/api/invoice/app/invoice/1.0/?service=/syncInvoiceOrder&14c4b06b824ec593239362517f538b29=8afe757107b215bb4799880a14b8d4a1&76a2173be6393254e72ffa4d6df1030a=6bf4947b8998e1f9030a719ac3305509" r = BasePage.syncInvoiceOrder(amount, sn, shopOrderSn, orderSn, Url) input = Cloud(self.driver) # input变量可以调用Cloud得方法 url = "http://invoice.sunmi.com/?orderSn=" + orderSn input.open(url) time.sleep(2) # 获取url nowurl = input.Get_url() if nowurl == "http://invoice.sunmi.com/?orderSn=" + orderSn: # 切换到个人开票 input.click( 'xpath', '//*[@id="root"]/div/div/div[2]/div/div/div[1]/div/div/div/div/div[1]/div[1]' ) # 点击邮件输入框,输入邮件地址 input.send_keys( 'xpath', '//div[3]/div[1]/div[2]/form/div[2]/div/div/span/span/input', '*****@*****.**') # 点击提交 input.click('xpath', '//form/div[4]/div/div/span/button') #pageobjects包内的方法 a = input.Get_text('xpath', '//*[@id="root"]/div/div/div/div/div/p') try: assert a in ('开票已完成', '开票申请已提交') print(' Test Pass.') except Exception as e: input.get_windows_img() # 调用基类截图方法 print('Test Fail.', format(e)) else: # 捕获当前文本 a = input.Get_text('xpath', '//*[@id="root"]/div/div/div/div/div/p') try: assert a in ('开票申请已提交') print(' Test Pass.') except Exception as e: input.get_windows_img() # 调用基类截图方法 print('Test Fail.', format(e))
def test_person_error_ok(self): #输入框验证错误提示 """ 这里一定要test开头,把测试逻辑代码封装到一个test开头的方法里。 :return: """ input = Cloud(self.driver) # input变量可以调用Cloud得方法 url = "http://invoice.sunmi.com/?orderSn=AUTOtest0000000008" input.open(url) time.sleep(2) # 切换到个人开票 input.click( 'xpath', '//*[@id="root"]/div/div/div[2]/div/div/div[1]/div/div/div/div/div[1]/div[1]' ) #点击提交 input.click('xpath', '//form/div[4]/div/div/span/button') #pageobjects包内的方法 a = input.Get_text('xpath', '//form/div[2]/div/div/div') try: assert "邮箱地址为必填项" == a print('Test Pass.') except Exception as e: input.get_windows_img() # 调用基类截图方法 print('Test Fail.', format(e))
def test_insert_user(self): driver = Cloud(self.driver) driver.open("http://mgt.test.sunmi.com/") #登陆MGT driver.mgt_login() #打开一级菜单 driver.mgt_click_invoice() #打开二级菜单 driver.mgt_click_SHJJGL() time.sleep(1) #删除数据库的user sql = "delete from invoice_user where taxpayer_num = '91310117350739745P1'" base_page.execute_sql(host, user, password, db, port, charset, sql) #新增商户 driver.mgt_insert_user( '91310117350739745P1', '界面自动化测试', '13975059149', ) #断言 #1、搜索刚新增的商户 driver.mgt_click_search('13975059149', '界面自动化', 0, 0) #2、获取搜索结果的企业名称 name = driver.Get_text("link_text", "界面自动化测试") assert name == "界面自动化测试" print("Test Pass")
def test_noindent(self): # 不存在的订单 input = Cloud(self.driver) # input变量可以调用Cloud得方法 url = "http://invoice.test.sunmi.com/?orderSn=dsklajlksajfk" # 不存在的订单 input.open(url) time.sleep(2) # 捕获当前文本 a = input.Get_text('xpath', '//*[@id="root"]/div/div/div/div/div/p') try: assert a == '请求超时,请稍后重试。' print(' Test Pass.') except Exception as e: input.get_windows_img() # 调用基类截图方法 print('Test Fail.', format(e))
def test_search(self): #进入电子发票 driver = Cloud(self.driver) driver.open("http://mgt.test.sunmi.com/") #登陆MGT driver.mgt_login() #打开一级菜单 driver.mgt_click_invoice() #打开二级菜单 driver.mgt_click_SHJJGL() time.sleep(1) #搜索订单 driver.mgt_click_search("13975059149", "公司", 0, 0) #断言 a = driver.Get_text( "xpath", "//*[@id='root']/div/main/div/div[2]/div/div/div[2]/div[2]/div/div/div/div/div/table/tbody/tr[1]/td[6]/span" ) assert a == "编辑" print("Test Pass")
def test_enterprise_invoice_fail(self): #企业点击提交 """ 这里一定要test开头,把测试逻辑代码封装到一个test开头的方法里。 :return: """ input = Cloud(self.driver) # input变量可以调用Cloud得方法 url = "http://invoice.sunmi.com/?orderSn=AUTOtest0000000008" input.open(url) time.sleep(2) #获取url nowurl = input.Get_url() if nowurl == "http://invoice.sunmi.com/?orderSn=AUTOtest0000000008": # 切换到企业开票 input.click( 'xpath', '//*[@id="root"]/div/div/div[2]/div/div/div[1]/div/div/div/div/div[1]/div[2]' ) # 点击企业全称输入框 input.send_keys( 'xpath', '//div[3]/div[2]/div[2]/form/div[1]/div/div/span/div/div[1]/span/input', '腾讯') time.sleep(2) # 选中模糊查询结果第一个 input.click( 'xpath', '//div[3]/div[2]/div[2]/form/div[1]/div/div/span/div/div[2]/div[1]' ) # 清空企业纳税人识别号,通过点击清空× input.click( 'xpath', '//*[@id="root"]/div/div/div[2]/div/div/div[3]/div[2]/div[2]/form/div[2]/div/div/span/span/span' ) # 输入特定的纳税人识别号,一定失败 input.send_keys( 'xpath', '//div[3]/div[2]/div[2]/form/div[2]/div/div/span/span/input', 'A12345678912345X12AA') # 企业邮箱地址输入 input.send_keys( 'xpath', '// div[3] / div[2] / div[2] / form / div[3] / div / div / span / span /input', '*****@*****.**') time.sleep(2) # 点击提交 input.click( 'xpath', '//*[@id="root"]/div/div/div[2]/div/div/div[3]/div[2]/div[2]/form/div[5]/div/div/span/button' ) time.sleep(5) # 捕获当前文本 a = input.Get_text('xpath', '//*[@id="root"]/div/div/div/div/div/p') try: assert a in ('请稍后重试', '开票申请已提交') print(' Test Pass.') except Exception as e: input.get_windows_img() # 调用基类截图方法 print('Test Fail.', format(e)) else: # 捕获当前文本 a = input.Get_text('xpath', '//*[@id="root"]/div/div/div/div/div/p') try: assert a in ('开票申请已提交') print(' Test Pass.') except Exception as e: input.get_windows_img() # 调用基类截图方法 print('Test Fail.', format(e))