简体   繁体   中英

Selenium with Java, IntelliJ and Gradle - The path to the driver executable must be set by the webdriver.gecko.driver system property

I'm trying to run my test (cucumber, java, intelliJ), but I get this exception thread:

java.lang.IllegalStateException: The path to the driver executable must be 
set by the webdriver.gecko.driver system property; for more information, see 
https://github.com/mozilla/geckodriver. The latest version can be downloaded 
from https://github.com/mozilla/geckodriver/releases

I am using Selenium 3.141.5 and Mozilla 63.0.1.

I try to lear with the book: "The Cucumber for Java Book" Some explanations are not about the current Versions, thus I get some troubles... But I hope you can help me

Here is my build.gradle:

plugins {
    id 'java'
}

group 'cucumber_cash_withdrawal'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile 'io.cucumber:cucumber-java:2.4.0'
    testCompile 'io.cucumber:cucumber-junit:2.4.0'
    testCompile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
    implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
    implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.5'
}

configurations {
    cucumberRuntime {
        extendsFrom testRuntime
    }
}

task cucumber() {
    dependsOn assemble, compileTestJava
    doLast {
        javaexec {
            main = "cucumber.api.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src/test/resources']
        }
    }
}

apply plugin: 'java'

task runApp(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    main = 'cash_withdrawal.AtmServer'
}

System.setProperty("webdriver.gecko.driver", pathToYourFirefoxExecutable);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM