python

import pytest,allure,os,time
from selenium import webdriver
class Testclass():
    @classmethod
    def setup_class(cls):
        cls.driver = webdriver.Chrome('Chrome/Application/chromedriver.exe')
        cls.driver.get("http://www.baidu.com")
        cls.driver.maximize_window()
        cls.driver.implicitly_wait(30)
    def test001(self):
        driver = self.driver
        driver.find_element_by_xpath('//*[@id="kw"]').send_keys("淘宝")
        driver.find_element_by_xpath('//*[@id="su"]').click()
        driver.find_element_by_xpath('//*[@id="3001"]/div/div[1]/div/div/h3/div/a[1]').click()
        driver.switch_to_window(driver.window_handles[1])
    def test002(self):
        driver = self.driver
        driver.find_element_by_xpath('//*[@id="J_LoginInfoHd"]/a[1]').click()
        driver.find_element_by_xpath('//*[@id="fm-login-id"]').send_keys('15961198627')
        driver.find_element_by_xpath('//*[@id="fm-login-password"]').send_keys('714816sba')
        time.sleep(5)
        driver.find_element_by_xpath('//*[@id="login-form"]/div[4]/button').click()
        time.sleep(5)
    def test003(self):
        driver = self.driver
        driver.find_element_by_xpath('//*[@id="mx_5"]/ul/li[1]/a/img').click()
        driver.switch_to_window(driver.window_handles[2])
        driver.find_element_by_xpath('//*[@id="J_isku"]/div/dl[1]/dd/ul/li[1]/a/span').click()
        driver.find_element_by_xpath('//*[@id="J_juValid"]/div[2]/a').click()

    @classmethod
    def teardown_class(cls):
        # time.sleep()
        # cls.driver.quit()
        pass

if __name__ == '__main__':
    pytest.main(['--alluredir', 'report/result', 'test_tb.py'])  # 生成json类型的测试报告
    split = 'allure ' + 'generate ' + './report/result ' + '-o ' + './report/html ' + '--clean'  # 将测试报告转为html格式
    os.system(split)  # system函数可以将字符串转化成命令在服务器上运行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值