五、FirefoxDriver和InternetExplorerDriver

FirefoxDriver
FirefoxDriver能够直接打开firefox浏览器运行代码支持Javascript,执行速度比HtmlUnitDriver慢,比InternetExplorerDriver快。
package selenium.test.googleSearch;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.*;
public class BaiduFirefoxDriver {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub 
		System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe"); 
		WebDriver driver = new FirefoxDriver();
		driver.get("http://www.baidu.com/");
	}

}


InternetExplorerDriver
InternetExplorerDriver只能运行在windows操作系统下。
package selenium.test.googleSearch;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class BaiduInternetExplorerDriver {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		WebDriver driver = new InternetExplorerDriver();
		driver.get("http://www.baidu.com/");

	}

}










你可能感兴趣的:(FirefoxDriver)