The following sample is slightly modified compared to sample1. It has not a fixed pausing period of 1 second. Instead the pausing is dynamic with a maximum time of 30 seconds.
This behavior is extremely helpful if you are testing with a service provider URL that is not https. In that case a security pop-up is displayed by Firefox that can not be confirmed programmatically. A interactive click on the popup might be necessary which may require different pausing times (depending on the user reaction).

Additionally in the sample checking for SSO success is done by validating the page title instead of a string in the page content.

The script itself is displayed in table view below. The lines in red are required to store the test results in the tool and the green fields mark a loop which is necessary to run through all test cases. Do not delete these lines.