TechnoCorner
TechnoCorner

Reputation: 5155

How to do headless protractor/jasmine testing?

I have got protractor installed with jasmine/coffeescripts with chromedriver.

I am running my tests and chrome starts and it runs everything. That's fine.

But, if i run this from remote (ssh) headless, it says

using ChromeDriver directly...
Spec started
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
The last active task was:
WebDriver.createSession()
    at <anonymous>
    at <anonymous>
    at <anonymous>
    at <anonymous>

  Going to the Connect pages and launch at dashboard
    ✗ Should login as admin and launch Location view (30 secs)
      - timeout: timed out after 30000 msec waiting for spec to complete

How can i run these tests in headless mode?

Thanks, R

Upvotes: 2

Views: 585

Answers (1)

cvakiitho
cvakiitho

Reputation: 1396

Only way I know about is xvfb, but it is a pain to get working imho. fortunately somebody already did that for us:

https://github.com/SeleniumHQ/docker-selenium So basically you only need to install docker

curl -sSL https://get.docker.com/ | sh

then start docker deamon

sudo service docker start

and then start hub + browser, or standalone browser:

docker run -d --name selenium-hub -p 4444:4444 selenium/hub:2.47.1
docker run -d --name chrome1 --link selenium-hub:hub selenium/node-chrome:2.46.0
docker run -d --name chrome2 --link selenium-hub:hub selenium/node-chrome:2.46.0
docker run -d --name firefox1 --link selenium-hub:hub selenium/node-firefox:2.46.0

or standalone:

docker run -d -p 4444:4444 selenium/standalone-chrome-debug:2.47.1

Also remember to kill docker containers, after tests, as they are not made to survive long :)

docker rm -f $(docker ps -a -q --filter 'name=chrome')
docker rm -f $(docker ps -a -q --filter 'name=firefox')
docker rm -f $(docker ps -a -q --filter 'name=selenium-hub')

And I almost forgot, inside your ptor config, or grunt args, or cli arg : seleniumAddress: 'http://<serverWithHubAddress>:4444/wd/hub',

Upvotes: 2

Related Questions