java+selenium3配置

来源:互联网 发布:怎样在淘宝做代销 编辑:程序博客网 时间:2024/06/08 00:49

由于Firefox的必要升级,导致之前的selenium2无法使用,只能对selenium进行升级

目前我的Firefox版本为v54.0,下载selenium3.4.0,下载selenium3必须要有的Firefox驱动geckodriver.exe,下载jdk8

Firefox:http://ftp.mozilla.org/pub/firefox/releases/

selenium:http://selenium-release.storage.googleapis.com/index.html

geckodriver:https://github.com/mozilla/geckodriver/releases

将selenium-server-standalone-3.4.0.jar及geckodriver.exe放到lib目录下,同时将selenium进行替换

原先我使用的是2.53.1,在右键项目-> Build Path -> Configure Build Path中进行删除,在右键selenium -> Build Path -> Add To Build Path中进行添加

selenium3.X目前需要jdk8的支持,所以还需要对编译环境进行配置

原先的java代码也需要进行修改

build.xml文件(如果是使用Junit的话):

<path id="RegressionTest.classpath"><pathelement location="bin" /><pathelement location="lib/selenium-server-standalone-3.4.0.jar" /><pathelement location="lib/junit.jar" /><pathelement location="lib/org.hamcrest.core_1.3.0.v201303031735.jar" /><pathelement location="lib/common-lang3.jar" /></path>

在driver启动代码中进行修改:

@Testpublic void initFirefox() throws Exception {System.setProperty("webdriver.firefox.marionette", "lib//geckodriver.exe");driver = new FirefoxDriver();driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);}


原创粉丝点击