seleniumselenium-gridserenity-bddcucumber-serenity

Multiple browser instances in serenity


Serenity version: 2.6.0

I have a feature in my application in which to test the real time chat feature. I used to open two incognito mode to test it manually but when it comes to automation, I am not sure how to achieve this?

is there away to open two browser instance to test real time chatting in a single machine using SERENITY?

if not, kindly suggest the best approach to deal with this situation like selenium grid/sauce labs.

I tried open multiple browser instance by calling open() method back to back but it just replaces the other opened.

enter image description here

Expected: Two browser instances need to be opened.

Actual: One instance replaced the another.


Solution

  • You should use two different actors to operate with separate browsers like this:

    @Managed
    WebDriver browser1;
    @Managed
    WebDriver browser2;
    
    Actor user1 = Actor.named("user1");
    Actor user2 = Actor.named("user2");
    
    user1.whoCan(BrowseTheWeb.with(browser1));
    user2.whoCan(BrowseTheWeb.with(browser2));
    
    user1.attemptsTo(Open.browserOn().thePageNamed("http://gooogle.com"));
    user2.attemptsTo(Open.browserOn().thePageNamed("http://gooogle.com"));
    

    You can check here too