How to use Chromedriver with Gagarin tests

chrome
circle.yml

#1

Hi, I’m trying to figure out how to set up and run Chromedriver in my test environment. I am able to successfully execute my tests locally, but when I deploy my code to Github, they fail in CircleCI’s test environment. I think this has something to do with my circle.yml file not configuring Chromedriver correctly, but I can’t find much information on what to do to configure it with my project. Thanks!


#2

Ive been been working with chromedriver lately so i may be able to help.

Do you have a public build url or a circle.yml i could take a look at?


#3

Sure…keep in mind like I mentioned in my first post, I haven’t been able to find much on what commands I need to use. I’m also new to CI, yml configuration files, and Chromedriver, so I’m more or less flying blindfolded with this:

dependencies:
  cache_directories:
    - ~/.meteor
  override:
    - meteor || curl https://install.meteor.com | /bin/sh
    - npm install -g gagarin

test:
  override:
    - gagarin --timeout 60000

#4

Sure, no worries at all.

I think the first step would be to start chromedriver, I’m using this chunk of code for that:

dependencies:
  post:
    # install chromedriver
    - wget https://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip
    # run chromedriver
    - ./chromedriver --url-base=wd/hub --port=9515  --verbose --log-path=$CIRCLE_ARTIFACTS/chromedriver.log:
        background: true

See if that helps you move forward :smile:


#5

Yes, that’s the type of information I was trying to find and couldn’t. However, I’m still getting an error that makes me think it did not initialize correctly. Here is the error:

 Error: [init({})] The environment you requested was unavailable.
at /home/ubuntu/nvm/v0.10.33/lib/node_modules/gagarin/node_modules/wd/lib/webdriver.js:129:15
at Request._callback (/home/ubuntu/nvm/v0.10.33/lib/node_modules/gagarin/node_modules/wd/lib/http-utils.js:87:7)
at Request.self.callback (/home/ubuntu/nvm/v0.10.33/lib/node_modules/gagarin/node_modules/wd/node_modules/request/request.js:368:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/ubuntu/nvm/v0.10.33/lib/node_modules/gagarin/node_modules/wd/node_modules/request/request.js:1219:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/ubuntu/nvm/v0.10.33/lib/node_modules/gagarin/node_modules/wd/node_modules/request/request.js:1167:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)

#6

Can you share your connect code for gagerin?


#7

I think I edited from my original post. This is what also is working on my local setup:

test:
  override:
    - gagarin -B --timeout 600000

#8

Since I can’t tell from the stack trace where it’s failing (doesn’t appear to reference your code at all) That’s kinda hard to trace.

What command are you using to launch locally, just ./chromedriver ? It’s possible my extra switches are making it mad, they were actually to test with electron and may not be applicable in your case.


#9

I took them out, but I got an error saying that a tag was expected. Here is my current circle.yml:

  cache_directories:
    - ~/.meteor
  override:
    - meteor || curl https://install.meteor.com | /bin/sh
    - npm install -g gagarin
  post:
    # install chromedriver
    - wget https://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip
    # run chromedriver
    - ./chromedriver

test:
  override:
    - gagarin -B --timeout 600000

Also, attached is a screenshot of the error.


#10

Think you be missing dependences: ? :smiley:


#11

That’ll do it :wink: I’m not sure how that got deleted, but I totally missed it. I tried running everything again, and the test hung when running Chromedriver. I tried adding the

background: true

that you had in your code, but it gave me the following error:

Any ideas to keep chromedriver from causing everything to hang? I normally run Meteor in one bash shell, chromedriver in another, and then run my Gagarin tests in a third locally.


#12

In order to add background: true you have to add a : at the end of the prior line so it knows to keep processing.

So

  • ./chromedriver:
    background: true

Ref https://circleci.com/docs/configuration#modifiers since discourse has decided to start not letting my indent correctly.


#13

So I should mention I really appreciate you sticking with me through this. I added a colon as you suggested to my code:

dependencies:
  cache_directories:
    - ~/.meteor
  override:
    - meteor || curl https://install.meteor.com | /bin/sh
    - npm install -g gagarin
  post:
    # install chromedriver
    - wget https://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip
    # run chromedriver
    - ./chromedriver:
      background: true

test:
  override:
    - gagarin -B --timeout 60000

These were the errors I got:

You’ll notice one of the errors on a previous post said ‘mapping values are not allowed here’. I don’t know if that was a semantic issue or something else going on.


#14

This is the second image…for some reason I was only allowed to put one image in the previous post:


#15

The background: true needs to be indented 2 more spaces, for some reason discourse wouldn’t allow me to type it that way, sorry :-/

- ./chromedriver:
    background: true

(And now it does)

https://circleci.com/gh/drazisil/wow_addon_updater/45#config


#16

Ok now I am actually making progress :slight_smile: The build failed the first time after fixing the indentation, but it was because the gagarin command was skipping the meteor build (in the event your server is already running). I removed the -B from the shell command, and it worked! Your help is greatly appreciated with this!


#17

Awesome! Please mark as solve when it works, and I’m sure others would love it if you are willing to share your working circle.yml file :smile:


#18

Done!

dependencies:
  cache_directories:
    - ~/.meteor
  override:
    - meteor || curl https://install.meteor.com | /bin/sh
    - npm install -g gagarin
  post:
    # install chromedriver
    - wget https://chromedriver.storage.googleapis.com/2.20/chromedriver_linux64.zip
    - unzip chromedriver_linux64.zip
    # run chromedriver
    - ./chromedriver:
        background: true

test:
  override:
    - gagarin --timeout 60000

#19

how would I specify the url-base argument to the chromedriver? I’m not getting how to do it in yml

update: figured it out

- ./chromedriver --url-base=wd/hub:
    background: true

#20