lundi 21 mars 2016

Gradle Geb specific browser

Currently I'm trying to automate my tests with Geb and Gradle and using Firefox the whole time. Now I'm at that point that I want to choose between different browser like Firefox, Chrome and Browserstack and/or run all tests with all browsers.

It sounds easy but I can't get the right solution. I read a few examples like: http://ift.tt/1Sd1ilO I created a few tasks like firefoxTest and chromeTest. At this point I'm ignoring the BrowserstackTests, Now the funny thing ist that if I run the chromeTest it's starting Firefox and I can't find a explanation who to choose between tests and I can't figure out thow does it the example from above.

Here is my current build.gradle.

def gebVersion = '0.13.1'
def seleniumVersion = '2.51.0'

apply plugin: 'groovy'

repositories {
    mavenCentral()
}

dependencies {
    testCompile "org.gebish:geb-spock:$gebVersion"
    testCompile("org.spockframework:spock-core:1.0-groovy-2.4")

    testRuntime "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
    testCompile "org.gebish:geb-junit4:$gebVersion"
}


task firefoxTest(type: Test) {
    dependencies {
        systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
        testCompile "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
    }

    systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
    systemProperty "geb.env", "firefox"
}

task chromeTest(type: Test) {
    dependencies {
        systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
        testCompile "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
    }

    systemProperty "geb.build.reportsDir", reporting.file("$name/geb")
    systemProperty "geb.env", "chrome"
}

Aucun commentaire:

Enregistrer un commentaire