0

I need to verify the text in a multiline alert but I really cannot make it work.

The alert is like:

- Please enter firstname:
- Please enter lastname:
- ..............................

And I use:

verifyEquals("Verify msg",
        ObjectHelp.closeAlertAndGetItsText(true),
        "Please enter firstname:Please enter lastname:");

But it gives me FALSE for some reason!

I tried to debug and the alert text is really "Please enter firstname:Please enter lastname:" so, no doubts on that.

How can I manage multiline alerts?

Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
user1944151
  • 353
  • 1
  • 4
  • 16

1 Answers1

1

I bet the actual text of the alert is not "Please enter firstname:Please enter lastname:".

It's more likely "Please enter firstname:\nPlease enter lastname:" (notice the \n).

You should confirm this in the page source, or the JS file containing the call.

Anyway, the right thing to assert here is

verifyEquals("Verify msg",
        ObjectHelp.closeAlertAndGetItsText(true),
        "Please enter firstname:\nPlease enter lastname:");
Petr Janeček
  • 37,768
  • 12
  • 121
  • 145