serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
718 stars 515 forks source link

Serenity launches 2 instances of Chrome if the driver parameter is not set in the @Managed annotation #509

Closed adlenton closed 8 years ago

adlenton commented 8 years ago

Hey guys,

This bug is basically a re-opening of https://github.com/serenity-bdd/serenity-core/issues/378. We're currently using serenity version 1.1.36 and face the same problem as the author described in the linked issue. Environment is Windows 10, Google Chrome 52 (latest).

Code is

@RunWith(SerenityRunner.class)
public abstract class SimpleTestTemplate {

    @Managed
    public WebDriver webdriver;

    @ManagedPages
    public Pages pages;

    @Steps
    public GuestUserSteps guest;

    @Steps
    public PlayerSteps player;
}
public abstract class SimpleTestTemplateWithLogin extends SimpleTestTemplate {

    RuntimePropertiesLoader runtimePropertiesLoader = new RuntimePropertiesLoader();
    private String password = runtimePropertiesLoader.getProperty("default.user.password");

    @Before
    public void log_in_and_select_the_world() {
        String currentUsername = getClass().getSimpleName();
        webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        webdriver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        guest.atStartPage().opens_the_start_page();
        if (webdriver.getCurrentUrl().contains("grepolis.com")) {
            guest.atLandingPage().logs_in_as(currentUsername, password);
        } else if (webdriver.getCurrentUrl().contains("grepo.dev")) {
            guest.atStartPage().logs_in_as(currentUsername, password);
        }
        player.atStartPage().selects_default_world();
        player.atMainPage().waits_for_gameload();
        player.atJSLevel().hide_dev_bar_if_visible();
    }
}

First instance is opened at line

webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

Second instance is opened at line

guest.atStartPage().opens_the_start_page();

Code of this method:

@Step
    public void opens_the_start_page() {
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
        getDriver().manage().deleteAllCookies();
        //this will basically just open the webdriver base url which is set in the serenity properties
        //it's just called from the start page to make it a bit more obvious what happens, even though it also might open the landingpage (GLPS)
        String url = runtimePropertiesLoader.getProperty("env.PARAM");
        getDriver().navigate().to(url);
        if (url.contains("grepolis.com")) {
            onLandingPage.waitForPageLoad();
        } else if (url.contains("grepo.dev")) {
            onStartPage.waitForPageLoad();
        }
        getDriver().manage().window().maximize();
    }

Setting the driver (chrome) in the managed annotation fixes the issue but doesn't help that much as we'd like to run the tests on multiple browsers.

Thanks for your help already! :)

wakaleo commented 8 years ago

Could you check if this issue appears in version 1.1.37.rc-7 or 1.1.37.rc-8?

adlenton commented 8 years ago

Unfortunately I could only find 1.1.37-rc.6 on mvnrepository (https://mvnrepository.com/artifact/net.serenity-bdd/serenity-core/1.1.37-rc.6) Is there another repo to get the rc 7 or 8? Side note: on rc 6 the issue still occurs.

wakaleo commented 8 years ago

Most of the RC releases are only deployed on Bintray ( https://bintray.com/bintray/jcenter) - you can find the latest RC versions there.


John Smart | Wakaleo Consulting | +44 7398 832273 Making smart teams collaborate better

http://johnfergusonsmart.com | reachme@johnfergusonsmart.com john.smart@wakaleo.com___

On 25 August 2016 at 2:24:42 PM, adlenton (notifications@github.com) wrote:

Unfortunately I could only find 1.1.37-rc.6 on mvnrepository ( https://mvnrepository.com/artifact/net.serenity-bdd/serenity-core/1.1.37-rc.6 ) Is there another repo to get the rc 7 or 8? Side note: on rc 6 the issue still occurs.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/serenity-bdd/serenity-core/issues/509#issuecomment-242384322, or mute the thread https://github.com/notifications/unsubscribe-auth/AADasgZU8OwWsST9MBugk_OiZB1JC7HHks5qjZeXgaJpZM4JrxQs .

adlenton commented 8 years ago

Thanks for your hint! Issue doesn't occur in this version anymore, great job! :+1:

wakaleo commented 8 years ago

Awesome, great to hear - I'll close this issue, but feel free to reopen if you have any other issues.

adlenton commented 8 years ago

Hi :) I'm very sorry to bother you again but in release 1.1.38 this issues is occurring again. Is there anything I could provide in order to help you tracking down the issue?

wakaleo commented 8 years ago

I can't reproduce this issue, could you provide a sample project that illustrates the problem?

adlenton commented 8 years ago

Should be reproducible with this one: https://github.com/adlenton/chrome_issues Thanks for taking the time to look into this one.

berlin-sky commented 7 years ago

Hi John, please can you let us know if this issue is resolved, I can still see this happening in 1.139.