Search code examples
docker-composecucumberselenium-gridnightwatch.js

How to pass an browser env parameter for nightwatch-api formerly nightwatch-cucumber?


Nightwatch-cucumber is deprecated and we should use Nightwatch-api as per the author.

I have a set up where I use selenium grid with both a Firefox and Chrome nodes running waiting to be activated. I have not set any webdriver settings in my project. I am still able to run tests but it only takes the default test setting.

How would be able to run tests specifying a browser other than the default?


Solution

  • As per the examples from repo, you should be able to pass it through two files (links below) which will enable you to execute them in desired browser (provided, it is configured in nightwatch.conf.js file).

    https://github.com/mucsi96/nightwatch-api/blob/master/packages/selenium-hub-example/test/server.js

    https://github.com/mucsi96/nightwatch-api/blob/master/packages/selenium-hub-example/test/support/setup.js

    Examples from Repo:

    Selenium Grid : https://github.com/mucsi96/nightwatch-api/tree/master/packages/selenium-hub-example

    Webdriver : https://github.com/mucsi96/nightwatch-api/tree/master/packages/cucumber-example

    Selenium standalone : https://github.com/mucsi96/nightwatch-api/tree/master/packages/cucumber-selenium-example

    Please accept this as answer if it helps in resolving your issue.