Search code examples
xmlnunithtmlunit

Page does returns a wrong collected alert


When going to a page it should display a message box by the alert javascript. But it seems like there's no error (that is supposed to happen since I have changed an innertext in an xml file that is needed for retrieving a list for the page).

Here's what is inside the aspx page:

If list = Null
alert("Sorry there's nothing to retrieve.")

For the test:

Dim docu As New XmlDocument
Dim path As String = "C:\Hallbjorn.xml"
docu.Load(path)
docu.SelectSingleNode("/Aria/Icelandic").InnerText = "Suburban"
docu.Save(path)

webCLient.getPage("https:/Storyline.com/Character1.htm")
collectedAlerts = New java.util.ArrayList()
webCLient.setAlertHandler(New CollectingAlertHandler(collectedAlerts))

Dim newPage = oldPage.getElementById("background").click
Assert.AreEqual("Sorry there's nothing to retrieve.", Convert.ToString(collectedAlerts))

The error message should be the one in the alert.


Solution

  • The setting of the alert handler must occur before clicking a button that is going to another page.