首页 > 编程语言 > 详细

第二个python自动化练习

时间:2016-10-12 14:03:41      阅读:178      评论:0      收藏:0      [点我收藏+]
 1 #Author:xiaoxiao
 2 
 3 from selenium import webdriver
 4 import unittest
 5 
 6 class DownLoad(unittest.TestCase):
 7     #初始化工作
 8     def setUp(self):
 9         #打开浏览器
10         self.driver = webdriver.Firefox()
11         self.driver.implicitly_wait(10)
12         self.driver.get("http://photo.163.com")
13     def testDownLoaf(self):
14         #找到了解更多按钮并点击
15         knowbutton = self.driver.find_element_by_link_text("了解更多")
16         knowbutton.click()
17         #获取窗口句柄
18         windowhanle = self.driver.current_window_handle
19         windowhanles = self.driver.window_handles
20         for handle in windowhanles:
21             if handle != windowhanle:
22                 self.driver.switch_to.window(handle)
23         #断言验证
24         self.assertEqual(self.driver.current_url,"http://photo.163.com/cloudphotos/","点击错误")
25         #获取iphone按钮并点击
26         iphonebutton = self.driver.find_element_by_id("J-iphone")
27         iphonebutton.click()
28         con = self.driver.find_element_by_id("J-xbox-title").text
29         #断言验证
30         self.assertEqual(con,"iPhone版下载","验证iphone版下载错误")
31     def tearDown(self):
32         #退出浏览器
33         self.driver.quit()
34 
35 if __name__ == __main__:
36     unittest.main()

 

第二个python自动化练习

原文:http://www.cnblogs.com/airener/p/5952294.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!