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

Alert on browser close prevents browser from closing #1225

Closed
zonie600 opened this issue Apr 26, 2018 · 3 comments
Closed

Alert on browser close prevents browser from closing #1225

zonie600 opened this issue Apr 26, 2018 · 3 comments

Comments

@zonie600
Copy link

zonie600 commented Apr 26, 2018

Our application pops up an "Are you sure?" type of alert when the browser closes while there is unsaved work. The issue I'm having is, when a test fails and the browser tries to close, the alert pops up and prevents the browser from closing. The alert can't be accepted because the webdriver has already been closed. Therefore, the browser just sits there blocking all other tests from executing. (We're in the process of getting Selenium Grid up and running, but this will still block one of the available slots.)

Let me ask generically first if there is an obvious solution that I'm missing. I've tried putting in code to accept the alert as the last step in the test, and in the @after and the @afterclass, to no avail. I also have these properties set:

serenity.restart.browser.for.each = scenario
serenity.restart.browser.frequency = 1

If more information is needed, I can post a code sample.

@pisarenco92
Copy link

@zonie600 Try to accept alert with: ((WebDriverFacade) getDriver()).getProxiedDriver().switchTo().alert().accept();

@zonie600
Copy link
Author

@pisarenco92 Nope, no luck. Here's what my test looks like.

@RunWith(SerenityParameterizedRunner.class)
@UseTestDataFrom(value="$DATADIR/account/new_account/CreateGenericNewAccount.csv")
public class BrokenTest {
private static Actor theUser = Actor.named("The user");

//Login data
private String username, password;

//New account page data
private String companyName, primaryPhone, workPhone, addressLine1, city, state, zipCode;

@Managed
public WebDriver browser;

@Before
public void setUp() {
    givenThat(theUser).can(BrowseTheWeb.with(browser));
}

@Steps
InitiateCreatingANewAccount initiateCreatingANewAccount;

@Test
@Issue("#1669")
@WithTagValuesOf({"BrokenTest"})
public void create_a_generic_new_account() {
    givenThat(theUser).wasAbleTo(LogIn.with(username, password));
    andThat(theUser).wasAbleTo(initiateCreatingANewAccount);
	// Below line commented out to intentionally break the test
	//andThat(theUser).wasAbleTo(CompleteTheEnterAccountInformationScreen.using(companyName));
    andThat(theUser).wasAbleTo(CompleteTheCreateAccountScreen.with(
            companyName, primaryPhone, workPhone, addressLine1, city, state, zipCode
    ));
}

@After
public void tearDown() {
    ((WebDriverFacade) getDriver()).getProxiedDriver().switchTo().alert().accept();
}

}

@zonie600
Copy link
Author

I did find this issue the other day. This seems to be the problem I'm dealing with. mozilla/geckodriver#1151

@wakaleo wakaleo closed this as completed Feb 12, 2022
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

3 participants