2

I have a batch file with below content:

%1 %2 --params.validFile=%3 --params.invalidFile=%4

I am starting it through power shell script:

$path= "<filePath>\start.bat"
$args= '"<filePath>\protractor" "<filepath>/conf.js" "<filepath>/invalidfile" "<filepath>/validfile"'
Write-Host "Executing: " $path $args
$process = Start-Process $path $args -RedirectStandardOutput stdout.txt" -RedirectStandardError "stderr.txt" -PassThru
$process.WaitForExit()
if ($process.ExitCode -eq 0){
  Write-Host "protractor cmdline complete"
  Exit 0
} else {
  Write-Error "protractor cmdline failed"
  Exit 1
}

Note:

  • filepath is the absolute path

  • invalid and valid files are just parameters to the test

Problem:

On running this as part of octopus deployment, the logs shows the "protractor cmdline failed" printed, but the octopus step never ends. It keeps on going forever

Could someone help in knowing how to integrate protractor with octopus?

  • My guess? You're doing it wrong. Octopus is typically used as a deploy server, not a build server. Meaning, I would bet that the packages required for the protractor tests to run on your Octopus server do not exist and that's why it's failing. For my setup, I have a Jenkins job that runs the protractor tests. The powershell script I run in Octopus just calls out to Jenkins to start the job and then exits. The results of the Jenkins job can then be configured to report back to where ever you want. In my case, it's slack. – tehbeardedone Nov 14 at 18:31
  • Hi we have manually installed all the dependencies , so the tests are running fine in the agent . The issue is only with the octopus step getting hung – PDHide Nov 14 at 19:57
  • @tehbeardedone And even if protractor test is failing , the question is why Exit 1 is not getting executed. " Protractor cmdline failed" message is getting printed – PDHide Nov 14 at 21:00
2

The issue was because the chromedriver was not exiting after test execution completes. This makes the octopus script to hang

[https://github.com/angular/protractor/issues/4690][1]

So the work around was to add directconnect to the conf.js

exports.config = {

  directConnect: true,

Also i fixed the powershell script as:

$process = Start-Process -FilePath "$ProtractorPath" -ArgumentList $args -PassThru
$process.WaitForExit()

Where,

$ProtractorPath= "<path>/protractor"
$args= '"<path>/conf.js" --params.value="bla"'

So now i am not executing protractor using batch file , but directly from powershell.

  • 1
    It makes sense to mark the answer as correct – wec Nov 15 at 11:09
  • I can mark it tomorrow only as per stack policy – PDHide Nov 15 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.