Selenium batch execution test case generates HTML result file

Source: Internet
Author: User

Use Htmltestrunner to run a test suite to automatically generate an HTML test report:
1 Importunittest, Htmltestrunner, sendmail_html2 ImportTime , Os3 4Case_dir ='d:\\pywork\\pyworkspace\\yzwx_selenium\\batch_case\\test_cases'5t = time.strftime ("%y%m%d_%h%m%s", Time.localtime ())6Html_name ='D:\\test_data\\auto_test_result\\result_'+ T +'. html'7Result_dir ='D:\\test_data\\auto_test_result'8 9 Ten defsuites_run_html (): One     " "use Htmltestrunner to run test suites to automatically generate HTML test reports" " A     #the Discover function iterates through the specified directory, filters the files conditionally, and returns to the list of test suites -Discover_suites = Unittest.defaultTestLoader.discover (Case_dir, pattern='test_*.py') -     Print(discover_suites) thefp = open (Html_name,'WB') -Runner =Htmltestrunner.htmltestrunner ( -stream=FP, -title='Automated test Report for hazardous weather projects in Asia', +description='use case execution:') - Runner.run (discover_suites) + fp.close () A     Print("test result file:", Html_name) at  -  - defdel_empty_html (): -     " "to delete an empty HTML file that was previously generated" " -Lastest_file =sendmail_html.find_new_file (Result_dir) -File_size =os.path.getsize (lastest_file) in     iffile_size: -         Pass to     Else: + Os.remove (lastest_file) -         Print("The last result file is empty, deleted! ", Lastest_file) the  *  $Del_empty_html ()#to delete an empty HTML file that was previously generatedPanax NotoginsengSuites_run_html ()#executing a test suite

Selenium batch execution test case generates HTML result file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.