下载Selenium的最新版本地址:http://selenium-release.storage.googleapis.com/index.html
友情提示:如果一直下载不了,可能是浏览器与下载工具的没有兼容,或者没安装下载工具的插件。用IE浏览器打开,可以完整下载。如果没有这个问题就忽略。
时至今日,Selenium已经到了3.3.1版了(2017年3月7日)。
自从Selenium3发布以来,火狐浏览器(Selenium支持火狐的技术最为成熟,因为可以方便获取从而控制网页信息,也是测试人员最喜欢用的浏览器之一)成为了一个普遍的问题。
因为Selenium3不支持向前支持火狐浏览器了,太高版本的火狐,运行会出现问题。
例如Java代码:(实现打开浏览器,输入"WebDriver",搜索后,关闭浏览器)
package com.selenium.test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class seleniumHello { public static void main(String[] args) { //如果火狐浏览器没有默认安装在C盘,需要自己确定其路径 System.setProperty("webdriver.firefox.bin", "D:/Program Files/Mozilla Firefox/firefox.exe"); //定义驱动对象为 FirefoxDriver 对象 WebDriver driver = new FirefoxDriver(); //打开的网址 driver.get("http://www.baidu.com/"); //定位输入框元素 WebElement txtbox = driver.findElement(By.name("wd")); //在输入框输入文本 txtbox.sendKeys("WebDriver"); //定位按钮元素 WebElement btn = driver.findElement(By.id("su")); //点击按钮 btn.click(); //关闭驱动 driver.close(); } }</span>