Skip to content
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

Multiple browsers not working #2

Open
csrenato opened this issue Mar 20, 2018 · 3 comments
Open

Multiple browsers not working #2

csrenato opened this issue Mar 20, 2018 · 3 comments

Comments

@csrenato
Copy link

Hello Helen.

First of all, thank you for providing the cucumber testcafe demo, it was of great help for me.

I would like to ask you if you had any problems running the tests in multiple browsers?

My code snippet from hooks.js:

return runner
.src('./test.js')
.browsers('chrome', 'firefox')
.run()
.catch(function (error) {
console.log(error);
});

The problem is:

Running the test in chrome and firefox -> both browsers open but tests start and run only on the first browser listed in "run". In this example, test run only in chrome.

Also, the second browser does not close after the test.

Did you have any similar issues or could you provide some clarification?

Thanks!

Renato

@csrenato
Copy link
Author

This is working for me now. So you can close the issue...

@bhreinb
Copy link

bhreinb commented Aug 27, 2018

Hi @csrenato do you mind sharing as to how you got this working within a cucumber context? Thanks in advance.

@csrenato
Copy link
Author

Hi @bhreinb

I've followed another path for this problem.

First, I have created a npm task in package.json for each browser/device I am testing on (npm run Chrome, npm run Firefox ...). Each of the tasks will run the test on a predefined port. Example:

"Chrome": "cucumber-js --world-parameters {\"port1\":\"1111\"\,\"port2\":\"1112\"\,\"skipJsErrors\":[\"true\"]\,\"browsers\":[\"chrome\"]\"\} --format json:reports/report.json"

Code from hooks:

function runTest(browsers, tcOptions) {
PORT = tcOptions.port1;

createTestCafe('localhost', tcOptions.port1, tcOptions.port2)
.then(function (tc) ........

After that I have created a Jenkins job for each of those npm tasks (for example: npm run Chrome). The job name would then be "Chrome", the other job would be Firefox and so on.

When I launch that particular job, I use the Jenkins job name variable to pass it in the npm task. Example from Jenkinsfile:

def NPM_TASK = sh (script: "echo $JOB_NAME ",returnStdout: true).trim()

sh "npm run $NPM_TASK"

This way, you can use only 1 Jenkinsfile for all of your tests and save yourself the trouble of maintaining multiple repositories and you can run all your tests in parallel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants