"Selenium" Htmltestrunner test report generation

Source: Internet
Author: User

__author__='Administrator'#Coding=utf-8 fromSeleniumImportWebdriver fromSelenium.webdriver.common.byImport by fromSelenium.webdriver.common.keysImportKeys fromSelenium.webdriver.support.uiImportSelect fromSelenium.common.exceptionsImportnosuchelementexceptionImportUnitTest, time, reImportHtmltestrunner#Introducing the Htmltestrunner packageclassBaidu (unittest. TestCase):defsetUp (self): Self.driver=Webdriver. Firefox () self.driver.implicitly_wait (30) Self.base_url="http://www.baidu.com/"self.verificationerrors=[] Self.accept_next_alert=TruedefTest_baidu_search (self): driver=self.driver driver.get (Self.base_url+"/") driver.find_element_by_id ("kw"). Send_keys ("163") driver.find_element_by_id ("su"). Click () time.sleep (2) Driver.close ()#Baidu set up use cases    defTest_baidu_set (self): driver=Self.driver#go to the Search Settings pageDriver.get (Self.base_url +"/gaoji/preferences.html")        #Set search results per page to 100Driver.implicitly_wait (30) M=driver.find_element_by_xpath (".//*[@id = ' Gxsz ']/tbody/tr[4]/td[2]/select") M.find_element_by_xpath ("//option[@value = ' + ')"). Click () time.sleep (5)        #saving information for settingsDriver.find_element_by_xpath (".//*[@id = ' Gxszbutton ']/input[1]"). Click () time.sleep (2) Driver.switch_to_alert (). Accept ()defTearDown (self): Self.driver.quit () self.assertequal ([], self.verificationerrors)if __name__=="__main__":    #Define a unit test Containertestunit=UnitTest. TestSuite ()#Adding test cases to the test ContainerTestunit.addtest (Baidu ("Test_baidu_search")) Testunit.addtest (Baidu ("Test_baidu_set"))    #define a report storage path that supports relative pathsfilename ='d:\\report\\result.html'FP= File (filename,'WB')    #Defining test ReportsRunner =Htmltestrunner.htmltestrunner (Stream=FP, title=u'Baidu Search test Report', Description=u'use case execution:')    #Run test CasesRunner.run (Testunit)

"Selenium" Htmltestrunner test report generation

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.