A second Python automation exercise

Source: Internet
Author: User

1 #Author:xiaoxiao2 3  fromSeleniumImportWebdriver4 ImportUnitTest5 6 classDownLoad (unittest. TestCase):7     #Initialization Work8     defsetUp (self):9         #Open BrowserTenSelf.driver =Webdriver. Firefox () OneSelf.driver.implicitly_wait (10) ASelf.driver.get ("http://photo.163.com") -     defTestdownloaf (self): -         #Find out more button and click theKnowbutton = Self.driver.find_element_by_link_text ("Learn More") - Knowbutton.click () -         #Get Window Handle -Windowhanle =Self.driver.current_window_handle +Windowhanles =Self.driver.window_handles -          forHandleinchWindowhanles: +             ifHandle! =Windowhanle: A Self.driver.switch_to.window (handle) at         #Assertion Validation -Self.assertequal (Self.driver.current_url,"http://photo.163.com/cloudphotos/","Click Error") -         #Get the iphone button and click -Iphonebutton = self.driver.find_element_by_id ("J-iphone") - Iphonebutton.click () -con = self.driver.find_element_by_id ("J-xbox-title"). Text in         #Assertion Validation -Self.assertequal (Con,"iphone version download","Verifying iphone version download error") to     defTearDown (self): +         #Exit Browser - self.driver.quit () the  * if __name__=='__main__': $Unittest.main ()

A second Python automation exercise

Related Article

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.