-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you run Cucumber features in Parallel? Add examples #426
Comments
Hi @gkushang this is feature of cucumberjs itself. I remember reading somewhere that it is still on experimental stage. But on googling found this link. https://stackoverflow.com/questions/45037239/running-cucumberjs-feature-files-in-parallel. Ideally, there should not be of too much difference. We will think about adding a example but if you figure out and send us a PR, we will be glad to have it merged, |
This is the official documentation related to parallel execution https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md#parallel-experimental |
@gkushang Did it work? |
Closing this due to no activity |
hi @spnraju could you please add the example? 👍 |
@mucsi96 @spnraju I'm pretty much on the same page. Cucumber creates slaves correctly, but it seems that Chromedriver session is already used by first slave...
We migrated to latest NW/Cucumber and removed Selenium...
I can share |
Hi @fergadipa , we will consider adding that but it will definitely take time as both of us are held up a little bit. Kindly note that we will be glad if someone can raise a Pull request for the same. Hi @tSte Thank you for the details. configs will be useful in analyzing the issue more. |
Okay then. Here's import { path as driverPath } from 'chromedriver';
import { launchUrl, isLocalhost, isHeadless } from './env.conf';
const globals = {
retryAssertionTimeout: 5 * 1000,
waitForConditionPollInterval: 100,
waitForConditionTimeout: (isLocalhost ? 10 : 50) * 1000,
};
const defaultChromeOptions = ['window-size=1920,1080', 'disable-gpu'];
const headlessChromeOptions = [...defaultChromeOptions, 'no-sandbox', 'headless'];
const desiredCapabilities = {
browserName: 'chrome',
test_workers: true,
javascriptEnabled: true,
acceptSslCerts: true,
webStorageEnabled: true,
locationContextEnabled: true,
applicationCacheEnabled: true,
chromeOptions: {
args: isHeadless ? headlessChromeOptions : defaultChromeOptions,
},
loggingPrefs: { browser: 'ALL' },
};
const screenshots = {
enabled: true,
on_error: false,
on_failure: true,
path: './reports/screenshots',
};
const webdriver = {
start_process: true,
server_path: driverPath,
port: 4444,
cli_args: ['--port=4444'],
};
const config = {
src_folders: ['./steps'],
output_folder: './reports',
custom_commands_path: './commands',
custom_assertions_path: './assertions',
webdriver,
test_settings: {
default: { webdriver, screenshots, desiredCapabilities, globals, launch_url: launchUrl },
},
};
export default config; The import { setDefaultTimeout, AfterAll, BeforeAll } from 'cucumber';
import { createSession, closeSession, startWebDriver, stopWebDriver } from 'nightwatch-api';
setDefaultTimeout(60000);
BeforeAll(async () => {
await startWebDriver();
await createSession();
});
AfterAll(async () => {
await closeSession();
await stopWebDriver();
}); NPM script: |
@tSte the config looks ok to me. I have not run into the issue as you experience with the latest nightwatch-api, cucumber 6, (even with older version of cucumber 5 and nightwatch-api, it was fine) Are you trying to run this in the Selenium Grid or just on your local sandbox?on local, I would suggest try use the Selenium-grid-node docker. there is docker example https://github.com/expphchen/nightwatch-starter/blob/master/docker-compose.yml and the instrucation: https://github.com/expphchen/nightwatch-starter/blob/master/README.md |
Hello All, a script is added in selenium example to run feature files in parallel here. There seems to be some issue in doing the same when we are using a chrome driver because of some port issues. I have tried this with pure Nightwatch and it seems to be working. I will investigate further and let you know if I can find a way to do it. |
Hello @spnraju , have you had any success with finding a way to run in parallel using the '--parallel' parameter? |
+1 |
@RazvanVuscan @tejasshekokar We have success to use the --parallel , as well as we are able to run this in selenium-grid and local chrome browser, but the local chrome browser, we see sometime the issue starting the browser due to the port, so we use selenium-grid docker image, and it works quite well. Here is the detail docker compose file, https://github.com/icloudphil/nightwatch-starter/blob/master/docker-compose.yml |
Still having issues with this. Using --parallel 2 causes the second process to fail binding. How does the test runner know the port of the second process? |
I use cucumber and had the same issue. I resolved it by setting a different port number for each process by using a function that returns the port number as follows, see below. In my Nighwatch config I just call that function. Please note, this is only needed when using the "start_process: true" option function getPort() { |
Hello everybody Is there an update on this? I am using nightwatch api with cucumber and I need to execute some features in parallel, the execution by scenarios does not work for me, I need it to be by features, I tried to use the cucumber-parallel module (https://www.npmjs.com/package/cucumber-parallel) but seems to be outdated with recent versions of cucumber Any ideas? I greatly appreciate your help |
Are you able to see it started 2 browsers on your local? |
Can you provide the example in a GitHub perhaps? You don’t need to use any package to make this work. The cucumber runner already support it. Please check out above comments. |
Thanks for your response I am using the following script in my package.json "test:parallel": "cucumber-js --require-module @babel/register --require cucumber.conf.js --require step-definitions --parallel 2 --format node_modules/cucumber-pretty" The problem is that this runs the scenarios in parallel and I need to run the features in parallel because some scenarios depend on other scenarios and if I run them in parallel my tests will fail. |
@egarc12 did you find any solution to run individual feature in parallel ? |
No :( |
I am looking at running Cucumber features in parallel. Do you have any example?
The text was updated successfully, but these errors were encountered: