1

I tried running selenium test (Node Js) on docker machine but it says "TypeError: module.exports.browser.isElementPresent is not a function".

Note:

  • I can successfully run this same selenium test on my local machine
  • I tried running the same test on docker then i encountered the error above

root@6cd7ab2eb6f7:/usr/src# npm run kongaezv2
npm info it worked if it ends with ok
npm info using npm@4.1.2
npm info using node@v7.6.0
npm info lifecycle cerebro@0.0.1~prekongaezv2: cerebro@0.0.1
npm info lifecycle cerebro@0.0.1~kongaezv2: cerebro@0.0.1

> cerebro@0.0.1 kongaezv2 /usr/src
> mocha --recursive tests/kongaezv2 -t 9000000 --reporter mochawesome

execFile: tests/kongaezv2
execFilename: tests/kongaezv2.json


  Konga EZ V2 Sanity Test
validating pagetitle
title = Konga Ez | Home
Title = Konga Ez | Home
Validation == PASS :: Page :Konga Ez | Home is displayed successfully
    1) Log in with Email and Password
ready to close browser
validating pagetitle
title = Konga Ez | Home
Title = Konga Ez | Home
Validation == PASS :: Page :Konga Ez | Home is displayed successfully
    2) Serach for an item
ready to close browser
validating pagetitle
title = Konga Ez | Home
Title = Konga Ez | Home
Validation == PASS :: Page :Konga Ez | Home is displayed successfully
    3) Add an item to cart
ready to close browser
validating pagetitle
title = Konga Ez | Home
Title = Konga Ez | Home
Validation == PASS :: Page :Konga Ez | Home is displayed successfully
    4) Checkout with POD
ready to close browser


  0 passing (48s)
  4 failing

  1) Konga EZ V2 Sanity Test Log in with Email and Password:
     TypeError: module.exports.browser.isElementPresent is not a function
      at Object.elementpresent (helpers.js:25:47)
      at Object.validateelementpresent (validations.js:57:13)
      at Object.clickbutton (actions.js:74:13)
      at frameworks/kongaezv2.js:67:19
      at node_modules/async/dist/async.js:3830:24
      at replenish (node_modules/async/dist/async.js:946:17)
      at node_modules/async/dist/async.js:950:9
      at eachOfLimit (node_modules/async/dist/async.js:975:24)
      at node_modules/async/dist/async.js:980:16
      at _parallel (node_modules/async/dist/async.js:3829:5)
      at Object.series (node_modules/async/dist/async.js:4684:5)
      at Object.login_with_email (frameworks/kongaezv2.js:65:15)
      at Context.<anonymous> (tests/kongaezv2/kongaezv2.js:20:19)
      at runTest (node_modules/selenium-webdriver/testing/index.js:164:22)
      at node_modules/selenium-webdriver/testing/index.js:185:16
      at new ManagedPromise (node_modules/selenium-webdriver/lib/promise.js:1085
:7)
      at controlFlowExecute (node_modules/selenium-webdriver/testing/index.js:18
4:14)
      at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:3092
:14)
      at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:
3075:27)
      at asyncRun (node_modules/selenium-webdriver/lib/promise.js:2982:25)
      at node_modules/selenium-webdriver/lib/promise.js:676:7
      at process._tickCallback (internal/process/next_tick.js:103:7)
  From: Task: Konga EZ V2 Sanity Test Log in with Email and Password
      at Context.ret (node_modules/selenium-webdriver/testing/index.js:183:10)
      at node_modules/selenium-webdriver/testing/index.js:102:5
      at ManagedPromise.invokeCallback_ (node_modules/selenium-webdriver/lib/pro
mise.js:1384:14)
      at TaskQueue.execute_ (node_modules/selenium-webdriver/lib/promise.js:3092
:14)
      at TaskQueue.executeNext_ (node_modules/selenium-webdriver/lib/promise.js:
3075:27)
      at asyncRun (node_modules/selenium-webdriver/lib/promise.js:2935:27)
      at node_modules/selenium-webdriver/lib/promise.js:676:7
      at process._tickCallback (internal/process/next_tick.js:103:7)

  2) Konga EZ V2 Sanity Test Serach for an item:
     TypeError: module.exports.browser.isElementPresent is not a function
      at Object.elementpresent (helpers.js:25:47)
      at Object.validateelementpresent (validations.js:57:13)
      at Object.sendkeys (actions.js:116:13)
      at frameworks/kongaezv2.js:104:19
      at node_modules/async/dist/async.js:3830:24
      at replenish (node_modules/async/dist/async.js:946:17)
      at node_modules/async/dist/async.js:950:9
      at eachOfLimit (node_modules/async/dist/async.js:975:24)
      at node_modules/async/dist/async.js:980:16
      at _parallel (node_modules/async/dist/async.js:3829:5)
      at Object.series (node_modules/async/dist/async.js:4684:5)
      at Object.search (frameworks/kongaezv2.js:98:15)
TobyFagboh
  • 50
  • 6
  • Did you install virtual display for docker container with selenium tests? – nick_gabpe May 15 '17 at 09:49
  • Not sure, but what i did was to install chrome using my docker file ## Install Google Chrome # RUN cd /tmp && \ # wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \ # dpkg -i google-chrome-stable_current_amd64.deb && \ # apt-get -y -f install RUN \ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list && \ apt-get update && \ apt-get install -y google-chrome-stable && \ rm -rf /var/lib/apt/lists/* – TobyFagboh May 15 '17 at 10:03
  • You should install something like [Xvfb](https://en.wikipedia.org/wiki/Xvfb). Then start it and after it. See more [here](http://stackoverflow.com/questions/6183276/how-do-i-run-selenium-in-xvfb) But this is only for case if you don't want to see actual UI. – nick_gabpe May 15 '17 at 11:08
  • Thanks @nick_gabpe installing xvfb worked for me. I used Chromium in Docker via Xvfb – TobyFagboh May 17 '17 at 11:12
  • if this helps can you can accept my answer. Thanks in advance. – nick_gabpe May 17 '17 at 13:18

2 Answers2

0

Thanks @nick_gabpe installing xvfb worked for me. I used Chromium in Docker via Xvfb

TobyFagboh
  • 50
  • 6
0

You should install Xvfb more info available here here

Community
  • 1
  • 1
nick_gabpe
  • 5,113
  • 5
  • 29
  • 38