0

I'm trying to write a test with testcafe that could generate conflicts in a document. For this I would need to be logged in with 2 different users in 2 different browser sessions (One being an incognito window) and open up the documents editor with each user and edit the same text. It is important that both users are in the editor when editing the content in order to generate conflicts.

Is there a way to open multiple browser sessions in 1 testcafe test? Or an alternative solution for manipulating a doc with the 2 different user roles at the same time?

How the test would look like:

  1. Open browser window
  2. Log in with User1
  3. Navigate to document editor (Tinymce)
  4. Open incognito browser (without closing the 1st window)
  5. Log in with User2
  6. Navigate to document editor
  7. With User1 edit "text" to "purple" then save
  8. With User2 edit "text" to "gold" then save
  9. Assert that conflict happens
Dzsonah
  • 125
  • 1
  • 11
  • 1
    TestCafe does not have a built-in way to launch browser windows with different options. The [Multiple Browser Windows](https://testcafe.io/documentation/402841/guides/advanced-guides/multiple-browser-windows) feature launches different windows in the same process, which prevents different options from being applied to them. So, if you want one of your users to be in normal mode and the others to be incognito, run two different tests at the same time and synchronize them. A little later, I will make an example for you to demonstrate a possible way to implement this. – Ilya Afanasenko Apr 26 '21 at 08:07

1 Answers1

0

I made an example for you of how you can run multiple TestCafe tests and synchronize them using promises: https://github.com/DevExpress/testcafe-example-multiuser-scenario

Clone this repository: git clone https://github.com/DevExpress/testcafe-example-multiuser-scenario.git

install the packages: npm install and run the tests with npm run test.

If you use this approach, your tests will look like this:

test('Some test', async t => {
    await stage('First stage');
    //do somthing

    await stage('Second stage');
    //do anything else

    stage('End');
});

And the script that will drive the stages:

    await user1.runStage('First stage'); //will run the 'First stage' in the test and wait for the next stage request

    await user1.runStage('Second stage'); //will run the 'Second stage'

    user1.runStage('End');
Ilya Afanasenko
  • 517
  • 2
  • 7