|
2#
楼主 |
发表于 2015-9-7 10:16:40
|
只看该作者
- #coding=utf-8
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.support.ui import Select
- from selenium.common.exceptions import NoSuchElementException
- import unittest, time, re
- import HTMLTestRunner
- class Bing(unittest.TestCase):
- def setUp(self):
- self.driver = webdriver.Firefox()
- self.driver.implicitly_wait(30)
- self.base_url = "http://www.bing.com/"
- self.verificationErrors = []
- self.accept_next_alert = True
- def test_bing_search(self):
- driver = self.driver
- driver.get(self.base_url + "/")
- driver.find_element_by_id("sb_form_q").send_keys("selenium webdriver")
- driver.find_element_by_id("sb_form_go").click()
- time.sleep(2)
- driver.close()
- def tearDown(self):
- self.driver.quit()
- self.assertEqual([], self.verificationErrors)
- if __name__ == "__main__":
- testunit = unittest.TestSuite()
- testunit.addTest(Bing("test_bing_search"))
- filename = "E:\\result1.html"
- fp = file(filename, 'wb')
- runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
- title=u'必应搜索测试报告',
- description=u'用例执行情况:')
- runner.run(testunit)
复制代码 |
|