browserstack / nightwatch-browserstack

Selenium examples for Nightwatch and BrowserStack Automate
https://www.browserstack.com
77 stars 62 forks source link

Provide example to run parallel_local script #56

Closed alexlazarciuc closed 1 year ago

alexlazarciuc commented 1 year ago

Hello,

I am having issues to setup the run to run the tests in parallel against the same browser in browserstack. I can do it locally, but not remote. I am trying to use parallel_local command from the package.json but those environement are not set. Can you please update the nightwatch conf file so it's easy for the community to setup parallel execution?

Thanks

abhimanyukoul commented 1 year ago

Hello @alexlazarciuc,

Thanks for raising this concern on our GitHub Repository Issues Section. I understand you cannot run your tests in parallel with our local testing feature, considering the environments browserstack.local_firefox and browserstack.local_chrome are not defined in the nightwatch.conf.js file.

While we work on updating the nightwatch.conf.js file, you can make the following changes to run multiple tests for the same browser on BrowserStack -

In the nightwatch.conf.js file, replace the section browserstack.local with the details given below

// capabilities to run a local test on BrowserStack 'browserstack.local_chrome_1': { ...browserStack, desiredCapabilities: { browserName: 'chrome', 'bstack:options' : { "os" : "OS X", "osVersion" : "Ventura", "buildName" : "Final-Snippet-Test", "sessionName" : "Selenium-4 Nodejs snippet test", "local" : "true", "seleniumVersion" : "4.0.0", userName: '${BROWSERSTACK_USERNAME}', accessKey: '${BROWSERSTACK_ACCESS_KEY}', }, } }, 'browserstack.local_chrome_2': { ...browserStack, desiredCapabilities: { browserName: 'chrome', 'bstack:options' : { "os" : "OS X", "osVersion" : "Monterey", "buildName" : "Final-Snippet-Test", "sessionName" : "Selenium-4 Nodejs snippet test", "local" : "true", "seleniumVersion" : "4.0.0", userName: '${BROWSERSTACK_USERNAME}', accessKey: '${BROWSERSTACK_ACCESS_KEY}', }, } }, 'browserstack.local_firefox_1': { ...browserStack, desiredCapabilities: { browserName: 'firefox', 'bstack:options' : { "os" : "Windows", "osVersion" : "10", "buildName" : "Final-Snippet-Test", "sessionName" : "Selenium-4 Nodejs snippet test", "local" : "true", "seleniumVersion" : "4.0.0", userName: '${BROWSERSTACK_USERNAME}', accessKey: '${BROWSERSTACK_ACCESS_KEY}', }, } }, 'browserstack.local_firefox_2': { ...browserStack, desiredCapabilities: { browserName: 'firefox', 'bstack:options' : { "os" : "Windows", "osVersion" : "11", "buildName" : "Final-Snippet-Test", "sessionName" : "Selenium-4 Nodejs snippet test", "local" : "true", "seleniumVersion" : "4.0.0", userName: '${BROWSERSTACK_USERNAME}', accessKey: '${BROWSERSTACK_ACCESS_KEY}', }, } }

In package.json file under scripts section replace existing parallel_local value with the one given below

"scripts": { "parallel_local": "node scripts/local.runner.js --test ./tests/local/local_test.js --env browserstack.local_firefox_1,browserstack.local_firefox_2,browserstack.local_chrome_1,browserstack.local_chrome_2" }

I hope this helps.

If you have questions, please contact BrowserStack Support via the Contact Us Form.

abhimanyukoul commented 1 year ago

Hello @alexlazarciuc - Please be informed that the required changes related to browserstack.local_chrome and browserstack.local_firefox in the nightwatch.conf.js file have been made and are available in the repository.

You should now be able to directly run nightwatch tests in parallel with the local testing feature by simply cloning the repository on your machine and running the test using the following command -

npm run parallel_local

alexlazarciuc commented 1 year ago

Thanks a lot!