klassijs/klassi-js

Browserstack command results in error

MxmRz opened this issue · 8 comments

MxmRz commented

Hey,

I just cloned the repo, filled in the right username and key in the browserstack.json file and tried executing the duckDuckGo-feature with the command from the repo:

node run bslocal chrome/@search

It results in this error:

C:\Users\***\*****\klassi-js-master>node run bslocal chrome/@search
internal/modules/cjs/loader.js:583
throw err;
^

Error: Cannot find module "C:\Users\***\*****\klassi-js-master\run"
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3) 

hi,
I cannot reproduce that error at all
can you give me a bit more info please

MxmRz commented

I am using Windows 10 and just downloaded the repo, run 'npm install' in a terminal window from within the project folder, changed the browserstack credentials and then tried to use the command to run a browserstack test from your documentation.
It results in the error I already posted.

I also set up a selenium standalone server and the tests worked fine with the node index.js -d -t @search command.

Do you have the C:\Users\***\*****\klassi-js-master\run directory? I do not. Or maybe it is a problem with the "run" command in node run bslocal chrome/@search ?

I will try the same thing on a different pc soon...

i am interested to know what you find, as i have never seen that before ...
as for "run" thats a built in command of node that runs any para under the scripts section of the package.json

MxmRz commented

Ok I just tried it on a different Win10 machine and I get the same error. I really dont know why the "run" command is not recognized as a command. It appears that "run" is recognized as the scripts name and that a script named "run" can not be found?

So I looked into the package.json script-part and just used the command for browserstack/bslocal in my cmd: "node runtime/remotes/browserstackLocal && node index.js -e -d -w browserstack -x"

It connected to browserstack but the tests did not work, see the log below:

C:\Users\Job\Desktop\klassi-js-master>node runtime/remotes/browserstackLocal && node index.js -e -d -w browserstack -x

Expecting a player build served at port: 8080

Connecting local to browserstack automate...
Connected.

Night gathers, and now my watch begins..
I am the sword in the darkness.

true - Browserstack local instance is running
@search
Feature: Searching for apps with duckduckgo

  @search
  Scenario Outline: User inputs some search data
    × failed
      AssertionError: BrowserStack requires a config type e.g. win10-chrome: expected undefined to be a string
          at getDriverInstance (C:\Users\Job\Desktop\klassi-js-master\runtime\world.js:100:12)
          at World.<anonymous> (C:\Users\Job\Desktop\klassi-js-master\runtime\world.js:265:19)
    Given The user arrives on the duckduckgo search page
    - skipped
    When they input duckduckgo app
    - skipped
    Then they should see some results
    - skipped
    × failed
      TypeError: driver.saveScreenshot is not a function
          at World.<anonymous> (C:\Users\Job\Desktop\klassi-js-master\runtime\world.js:339:18)
    × failed
      TypeError: driver.end is not a function
          at World.<anonymous> (C:\Users\Job\Desktop\klassi-js-master\runtime\world.js:318:21) 

It produces the same Errors for all other tests and ends with this error:

Unhandled rejection VError: an AfterAll hook errored, process exiting: runtime\world.js:284: driver.pause is not a function
    at C:\Users\Job\Desktop\klassi-js-master\node_modules\cucumber\lib\runtime\index.js:85:21
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\util.js:16:23)
    at PromiseSpawn._promiseFulfilled (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\generators.js:97:49)
    at _drainQueueStep (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:142:12)
    at _drainQueue (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:131:9)
    at Async._drainQueues (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)
MxmRz commented

Of course! Not sure why I forgot about it.... So I just attached the broswer and test like this:
node runtime/remotes/browserstackLocal && node index.js -e -d -w browserstack -x chrome/@search

Is that the right way?

When running it in cmd the tests fail because of the Screenshot Match. Output looks like this:

2) Scenario: User inputs some search data # features\duckDuckGo-search.feature:17
   √ Before # runtime\world.js:264
   √ Given The user arrives on the duckduckgo search page # step_definitions\duckDuckGo-search-steps.js:10
   × When they input angry birds # step_definitions\duckDuckGo-search-steps.js:14
       Error: true - Screenshot Match Failed for angry birds_1-0.png with a tolerance difference of 1.5699999999999998 - expected: 0.1 but got: 1.67
           at Function.<anonymous> (C:\Users\Job\Desktop\klassi-js-master\node_modules\cucumber\lib\user_code_runner.js:107:21)
           at Generator.throw (<anonymous>)
           at Generator.tryCatcher (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\util.js:16:23)
           at PromiseSpawn._promiseRejected (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\generators.js:107:10)
           at Promise._settlePromise (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\promise.js:576:26)
           at Promise._settlePromise0 (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\promise.js:614:10)
           at Promise._settlePromises (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\promise.js:690:18)
           at _drainQueueStep (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:138:12)
           at _drainQueue (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:131:9)
           at Async._drainQueues (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:147:5)
           at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\Job\Desktop\klassi-js-master\node_modules\bluebird\js\release\async.js:17:14)
           at runCallback (timers.js:705:18)
           at tryOnImmediate (timers.js:676:5)
           at processImmediate (timers.js:658:5)
           at process.topLevelDomainCallback (domain.js:120:23)
   - Then they should see some results # step_definitions\duckDuckGo-search-steps.js:19
   √ After # runtime\world.js:336
       Attachment (image/png)
   √ After # runtime\world.js:315

In the Browserstack GUI I can see the screenshots browserstack takes and the video it takes. The tests run perfectly there....

node runtime/remotes/browserstackLocal && node index.js -e -d -w browserstack -x chrome -t @search
This is the correct way if you are running it freom the command line

hi
Just realise that the command was wrong its not 'node run' its
npm run bslocal chrome/@search

As for the image failure thats the correct behaviour as you took the baseline image while running locally and then you ran it via browserstack so the image will be different as the setting (resolution) for the browser is set for browserstack but not for local runs.