serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

Launching chrome while Mobile Application is opened #195

Open Errr0rr404 opened 5 years ago

Errr0rr404 commented 5 years ago

I'm trying to launch my browser while I have some tests running on Mobile Device.

My test case looks like this :

  1. Open Mobile Application
  2. Verify some elements
  3. Launch the browser and navigate to specific URL
  4. Validate the same elements as found from the Mobile device and make sure they are same

so for this, once I'm calling new browser instance in the code, Serenity is still taking the screenshot from the previous instantiated browser. how do i make serenity take screenshot and report from both driver instance ??

wakaleo commented 5 years ago

You could do this fairly easily using Screenplay, e.g.

public class AddTodosWithDifferentActors {

    private Actor james = Actor.named("James");
    private Actor jill = Actor.named("Jill");

    @Managed(driver = "firefox")
    private WebDriver hisBrowser;

    @Managed(driver = "chrome")
    private WebDriver herBrowser;

    @Before public void jamesCanBrowseTheWeb() {
        james.can(BrowseTheWeb.with(hisBrowser));
        jill.can(BrowseTheWeb.with(herBrowser));
    }

    @Test
    public void should_be_able_to_complete_a_todo() {

        givenThat(james).wasAbleTo(Start.withAnEmptyTodoList());

        andThat(jill).wasAbleTo(Start.withAnEmptyTodoList());

        when(james).attemptsTo(
                AddATodoItem.called("Walk the dog")
        );

        when(jill).attemptsTo(
                AddATodoItem.called("Feed the dog")
        );

        then(james).should(
                seeThat(TheItemStatus.forTheItemCalled("Walk the dog"), is(Active))
        );
        and(jill).should(
                seeThat(TheItemStatus.forTheItemCalled("Feed the dog"), is(Active))
        );

    }
}