Beispiel #1
0
    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))
Beispiel #2
0
from framework.base_page import BasePage
import requests

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)
print(r)
url = "http://invoice.sunmi.com/?orderSn=" + orderSn
print(url)