一、概述
WebDriver加载浏览器,我们需要掌握主流的三个浏览器的使用,谷歌、火狐和IE。
二、基本目录结构
其中files下存放的是相应使用的浏览器对应的driver。lib下存储的是selenium2使用的jar包。
三、三种浏览器的启动方式
1、FireFox火狐浏览器启动
实现代码如下:
package com.webdriver.selenium2; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver.Navigation; import org.openqa.selenium.firefox.FirefoxDriver; public class FireFoxDemo { public static void main(String[] args) { //实例化火狐浏览器 WebDriver driver = new FirefoxDriver(); //打开导航栏 Navigation na = driver.navigate(); //导航到百度 na.to("http://www.baidu.com"); //关闭浏览器 driver.close(); driver = null; } }
请注意selenium_webdriver是默认使用firefox来进行浏览器加载的,所以FireFox是在标准目录下,如果我们使用其他的浏览器进行加载webdriver,比如Chrom。我们