Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Selenium webdriver-manager from Gradle

I am trying to start Selenium from Gradle in order to run Protractor tests.

Here is my Gradle script:

//main task to run protractor tests
task uiTests << {
    println "Starting protractor tests"
}

//start Selenium server
task startSelenium << {
    println "Starting Selenium..."
    ant.exec(executable: '/bin/bash', spawn: true) {
        arg(value:'webdriver-manager')
        arg(value:'start')
    }
}

//run protractor
task runProtractor(type: Exec) {
    commandLine 'protractor', 'bignibou-client/protractor.conf.js'
}

//start selenium, then run protractor
uiTests.dependsOn([startSelenium, runProtractor])

However, the output seems to indicate that the Selenium process has not being started:

 :runProtractor
    Using the selenium server at http://localhost:4444/wd/hub
    [launcher] Running 1 instances of WebDriver

/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172
      callback(new Error(message));
               ^
Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:172:16)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at Socket.socketErrorListener (_http_client.js:259:9)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at emitErrorNT (net.js:1250:8)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)
From: Task: WebDriver.createSession()
    at Function.webdriver.WebDriver.acquireSession_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
    at Function.webdriver.WebDriver.createSession (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
    at [object Object].Builder.build (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
    at [object Object].DriverProvider.getNewDriver (/usr/local/lib/node_modules/protractor/lib/driverProviders/driverProvider.js:38:7)
    at [object Object].Runner.createBrowser (/usr/local/lib/node_modules/protractor/lib/runner.js:182:37)
    at /usr/local/lib/node_modules/protractor/lib/runner.js:263:21
    at _fulfilled (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:797:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:826:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/protractor/node_modules/q/q.js:759:13)
    at /usr/local/lib/node_modules/protractor/node_modules/q/q.js:525:49
[launcher] Process exited with error code 1
:runProtractor FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':runProtractor'.
> Process 'command 'protractor'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Can anyone please provide informed tips and guidance?

like image 480
balteo Avatar asked Oct 11 '15 13:10

balteo


1 Answers

By referring the webdriver-manager script directly as shown below sorted the issue:

//main task to run protractor tests
task uiTests << {
    println "Starting protractor tests"
}

//start Selenium server
task startSelenium << {
    println "Starting Selenium..."
    ant.exec(executable: 'webdriver-manager', spawn: true) {//CHANGED!!
        arg(value: 'start')
    }
}

//run protractor
task runProtractor(type: Exec) {
    commandLine 'protractor', 'bignibou-client/protractor.conf.js'
}

//start selenium, then run protractor
uiTests.dependsOn([startSelenium, runProtractor])
like image 111
balteo Avatar answered Oct 13 '22 07:10

balteo