selenium基于Java启动火狐浏览器56.0、启动谷歌浏览器62版本
依次键附件图:
第一步:配置buidpath
1、新建一个User libraries:window --》 preferences --》java --》New (新建一个libraries名为selenium) --》Add External JARs..(添加seleniumjar包)--》apply and Close
2、在buildpath中添加新建User libraries:右键项目名 --》 Build Path --》 configure Build Path --》 Libraries --》Add Library --》选择User Library
第二步:在项目中新建一个文件夹Files,将chromedriver、geckodriver放在该文件夹下方
第三步:启动Firefox浏览器、chrome浏览器代码如下
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testSeleNium {
private static WebDriver dr= null;
public static void main(String[] args) throws Exception{
//设置打开Firefox浏览器路径
/*System.setProperty("webdriver.gecko.driver", "F: