I'm updating a Selenium program I wrote a while back and part of it has stopped working. I want to go through a whole series of links on a page, click on each, making sure that some expected text is present. But sometimes a log-in page (https://library.med.nyu.edu/sso/ezproxy\_form.php) appears before the desired page, in which case I need to log in before checking the page. The problem is, no matter what string I put in to check whether I've landed on the log in page, Selenium concludes it's not present and skips logging in, obviously causing everything else to fail. See below--I'm not sure that was actually the problem. It seems to be instead that it's rushing through the "if we need to sign in" code without actually signing in, then obviously failing the main part of the test because it's not on the right page.

Here's the code--does anyone see my mistake?

```
       for (int i = 0; i < Resources.size(); i++) {
        try {
                        selenium.open("/");
                        selenium.click("link=" + Resources.get(i).link);
                        selenium.waitForPageToLoad("100000");
                        if (selenium.isTextPresent("Please sign in to access NYUHSL e-resources")) {
                            selenium.type("sso_user", kid);
                            selenium.type("sso_pass", password);
                            selenium.click("name=SignIn");
                            selenium.waitForPageToLoad("100000");
                        }

                        if (!selenium.isTextPresent(Resources.get(i).text)) {
                            outfile.println(Resources.get(i).name + " failed");
                        }
                    } catch (Exception e) {
                        outfile.println(Resources.get(i).name + " could not be found--link removed?");
                    }
       }

```