If you want to run your Selenium (WebDriver) tests from Gradle you can do it like this:
1. Add Jetty plugin to build.gradle
:
apply plugin: 'jetty'
2. Create a src/selenium/java
folder in you project root.
3. Add a SourceSet to build.gradle
:
sourceSets { selenium }
4. Add Selenium dependencies to build.gradle
:
seleniumCompile 'junit:junit:4.11' seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.30.0'
Add jettyDaemon
and selenium
tasks to build.gradle
:
task jettyDaemon(type: org.gradle.api.plugins.jetty.JettyRun) { daemon = true } task selenium(type: Test, dependsOn: jettyDaemon) { testClassesDir = sourceSets.selenium.output.classesDir classpath = sourceSets.selenium.runtimeClasspath }
5. If you are using Eclipse, add Selenium dependencies to the Eclipse classpath in build.gradle
:
eclipse { classpath { plusConfigurations += configurations.seleniumCompile } }
You can now place you Selenium tests in src/selenium/java
and run:
gradle clean selenium