我們來看一下如何在Eclipse下使用Java來編寫webdriver的case。需要準(zhǔn)備的東西:jdk1.6、eclipse、selenium-server-standalone-2.21.0.jar包。我使用的瀏覽器是Firefox的,要注意一下你的Firefox的版本是否和你的selenium sever的版本匹配。
	  selenium server可以到selenium的官網(wǎng)下載:http://seleniumhq.org/
	  首先在eclipse里新建一個java project--Test,然后在Test項目下新建一個文件夾lib,lib原來放selenium的server包。如下圖所示:
	
然后將selenium加入到build path里:選中項目右鍵-->Build Path-->Configure Build path,然后點(diǎn)擊add jars-->選我們項目下的selenium server可以了。
	
	  到這里我們的準(zhǔn)備做好了。
	  下面新建一個java的類,來體驗一下selenium webdriver。
	<span style="font-size:18px;">
	package com.beyondtest;
	import org.openqa.selenium.By;
	import org.openqa.selenium.WebDriver;
	import org.openqa.selenium.firefox.FirefoxDriver;
	public class testbaidu {
	/**
	* @param args
	*/
	public static void main(String[] args) {
	// TODO Auto-generated method stub
	//設(shè)置瀏覽器driver
	WebDriver driver;
	driver=new FirefoxDriver();
	//打開百度的首頁
	driver.get("http://www.baidu.com");
	//找到輸入框,輸入“北京博測科技”,并單擊百度一下按鈕
	driver.findElement(By.id("kw")).clear();
	driver.findElement(By.id("kw")).sendKeys("北京博測科技");
	driver.findElement(By.id("su")).click();
	//關(guān)閉瀏覽器
	driver.close();
	}
	}
	</span>
	  OK,強(qiáng)大吧。接下來我們將一點(diǎn)一點(diǎn)深入的去學(xué)習(xí)這個強(qiáng)大的工具。