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函数可以将字符串转化成命令在服务器上运行
python
于 2022-04-26 22:14:51 首次发布
46万+

被折叠的 条评论
为什么被折叠?



