selenium+python笔记4

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@desc: 使用unittest组织用例
"""
from selenium import webdriver
import unittest
import time class TestSearch(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.maximize_window()
self.driver.implicitly_wait(10)
self.base_url = "http://www.baidu.com" def test_baidu(self):
driver = self.driver
driver.get(self.base_url + "/") driver.find_element_by_id("kw").clear()
driver.find_element_by_id("kw").send_keys("unittest")
driver.find_element_by_id("su").click() time.sleep(2)
title = driver.title
self.assertEqual(title, u"unittest_百度搜索") def tearDown(self):
self.driver.quit() if __name__ == "__main__":
unittest.main()
上一篇:Android 使用 RemoteViews 发送自定义通知 ,遇到 Couldn't expand RemoteViews问题总结


下一篇:eclipse+Maven插件报错:-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.