# Selenium server pre-running?

**URL:** <https://discuss.circleci.com/t/selenium-server-pre-running/7640>\
**Category:** Build Environment\
**Tags:** selenium\
**Created:** [October 25, 2016, 7:23am UTC](https://discuss.circleci.com/t/selenium-server-pre-running/7640 "2016-10-25T07:23:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![olalonde](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/olalonde/32/16099_2.png) [@olalonde](https://discuss.circleci.com/u/olalonde)\
**Post date:** [October 25, 2016, 7:23am UTC](https://discuss.circleci.com/t/selenium-server-pre-running/7640/1 "2016-10-25T07:23:43Z")

</div>

Does anyone know if the circle build environment comes with selenium server? I’m trying to run a Node.js script that uses the local selenium server but it fails with this error:

```auto
{ Error: Couldn't connect to selenium server
    at end() - take-screenshots.js:40:8
  message: 'Couldn\'t connect to selenium server',
  type: 'RuntimeError',
  seleniumStack: 
   { status: -1,
     type: 'ECONNREFUSED',
     message: 'Couldn\'t connect to selenium server',
     orgStatusMessage: 'Couldn\'t connect to selenium server' } }

```

The script looks like this:

```auto
const webdriverio = require('webdriverio')
const baseURL = 'http://localhost:5000'
const dir = process.env.CIRCLE_ARTIFACTS
const scr = str => dir + '/' + str
const u = str => baseURL + str

const client = webdriverio
  .remote({ desiredCapabilities: { browserName: 'chrome' } })
  .init()

    client
      .init()
      .url(u('/'))
      .saveScreenshot(scr('homepage.png'))
      .end()

```

The script works fine on my local machine with `selenium-server` running.

---

<div class="post-metadata">

**Author:** ![tripper54](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/tripper54/32/24461_2.png) [@tripper54](https://discuss.circleci.com/u/tripper54)\
**Post date:** [October 26, 2016, 10:10pm UTC](https://discuss.circleci.com/t/selenium-server-pre-running/7640/2 "2016-10-26T22:10:23Z")

</div>

There is no mention of selenium server on the listings of software installed on the build images in the docs.

You can add it via circle.yml easily enough:

```auto
    - wget http://selenium-release.storage.googleapis.com/2.44/selenium-server-standalone- 2.44.0.jar
    - java -jar selenium-server-standalone-2.44.0.jar:
        background: true

```

---

<div class="post-metadata">

**Author:** ![olalonde](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/olalonde/32/16099_2.png) [@olalonde](https://discuss.circleci.com/u/olalonde)\
**Post date:** [October 26, 2016, 11:53pm UTC](https://discuss.circleci.com/t/selenium-server-pre-running/7640/3 "2016-10-26T23:53:12Z")

</div>

Thanks, that’s what I ended up doing (with caching). I had to use phatomjs though because I couldn’t get chrome to work (it would just hang or tell me there was an error when connecting).

```yaml
dependencies:
  cache_directories:
    - "~/cache"
  pre:
    - mkdir -p ~/cache
  post:
    # only downloads if not already in cache
    - cd ~/cache && wget -nc http://selenium-release.storage.googleapis.com/3.0/selenium-server-standalone-3.0.1.jar
    - java -jar ~/cache/selenium-server-standalone-3.0.1.jar:
          background: true

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/selenium-server-pre-running/7640/4 "2018-06-18T11:38:49Z")

</div>


