Selenium IDE: Why assertAlert did not work?

Linh Do
2 min readOct 14, 2021

First of all, be aware that when running the test in Selenium IDE, you cannot see the prompt if this alert message is written by javascript. In the latest version of Selenium IDE, there are few command support for popup such as assert alert, assert prompt, webdriver answer on visible prompt, assert confirmation, choose ok on next confirmation, etc. And the command to store alert is no longer supported.

So, the problem is that you cannot print out the message on the prompt to compare with the message you input in “assert alert”. And many people including me faced the issue of verifying the popup message. It’s always failed with the ambiguous reason “Alert message doesn’t match actual message” while you don’t really know what the “actual message” is.

After reading hundreds of posts on StackOverflow as well as another web, I cannot find the solution. Most of them refer to the previous version of Selenium IDE when many commands supporting for alert were still available. Then I tried my own:

Write a very basic HTML form to prompt a popup and let Selenium IDE work on it:

<button onclick=”myFunction()”>Click me</button><script>
function myFunction() {
alert(“I am an alert box!”);
}
</script>

Selenium IDE worked totally fine with this simple popup. So the reason could be the multiline message? Yes, bingo!

The root cause is that when you use Selenium IDE to record the popup message, it omitted all “/n” in the original message. For example:

The popup message that Selenium IDE automatically records is:

Errors have occurred during the processing of your form.Please make the following corrections:

While the original one is “Errors have occurred during the processing of your form.\n\nPlease make the following corrections:

So I had to obtain the message manually to make the assert alert works.

This is absolutely a drawback of Selenium IDE.

--

--