Hi All,
I've asked this on Stack Overflow, so please don't mind the repaste:
Here's the issue. I am using Serenity to run tests and PageObject is handling all my actions, either through Serenity's steps or by direct reference in Junit's tests.
The scenario I am currently working on is simple:
1. Enter date into a field (input "99999999").
2. Click Submit button.
3. Get popup alert messages.
a. Get "The year is invalid." msg first.
b. Get "Invalid Receipt Date format." msg second.
However, PageObject seems to immediately jump to the second message and completely ignores the first one. My implementation is somewhere along these lines:
@Test
public void receiptDateFieldIncorrectDateFormat() {
page.open();
steps.inputIntoReceiptDateField("99999999");
steps.clickSubmitButton();
String firstMsg = page.getAlert().getText();
page.getAlert().accept();
String secondMsg = page.getAlert().getText();
page.getAlert().accept();
Assert.assertEquals("The year is invalid.", firstMsg);
Assert.assertEquals("Invalid Receipt Date format.", secondMsg);
}
I have tried implementing waits with no result. Can someone explain to me how this works and why is the first alert omitted? PageObject does not seem to have functionality to cycle through multiple alerts, or has it?
Thank you!