Selenium是一個web的自動化測試工具,和其它的自動化工具相比來說其主要的特色是跨平臺、跨瀏覽器。
	  支持windows、linux、MAC,支持ie、ff、safari、opera、chrome等。
	  此外還有一個特色是支持分布式測試用例的執(zhí)行,可以把測試用例分布到不同的測試機器的執(zhí)行,相當于分發(fā)機的功能。
	  關于selenium的原理、架構、使用等可以參考其官網的資料,這里記錄如何搭建一個使用python的selenium測試用例開發(fā)環(huán)境。其實用python
	  來開發(fā)selenium的方法有2種:一是去selenium官網下載python版的selenium引擎;還有一種沒有操作過,這里不列出來了,有興趣的朋友可以自行查閱資料
	  這里記錄的是第一種搭建方式:
	  1.安裝python2.7x32或者x64版本
	  2.安裝pip工具
	  3.直接使用pip安裝selenium,命令為:pip install -U selenium
	  如果測試成功會看到打開瀏覽器后進行google搜索。另外selenium分版本1和版本2,這里安裝是版本2的selenium。派生到我的代碼片
	#-*-coding:utf-8-*-
	from selenium import webdriver
	from selenium.common.exceptions import TimeoutException
	from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
	import time
	# Create a new instance of the browser driver
	driver = webdriver.Chrome()  ##可以替換為IE(), FireFox(),但前提是配置了各自瀏覽器的Driver,火狐在我自己使用中如果瀏覽器和驅動不兼容,瀏覽器在啟動和退出是會報停止工作,此處注意
	# go to the google home page
	driver.get("http://www.google.com")
	# find the element that's name attribute is q (the google search box)
	inputElement = driver.find_element_by_name("q")
	# type in the search
	inputElement.send_keys("Cheese!")
	# submit the form. (although google automatically searches now without submitting)
	inputElement.submit()
	# the page is ajaxy so the title is originally this:
	print driver.title
	try:
	# we have to wait for the page to refresh, the last thing that seems to be updated is the title
	WebDriverWait(driver, 10).until(lambda driver : driver.title.lower().startswith("cheese!"))
	# You should see "cheese! - Google Search"
	print driver.title
	finally:
	driver.quit()
	#==================================