我正在更新一个Selenium程序,我写了一段时间,但它的一部分已停止工作。我想浏览一个页面上的一系列链接,点击每个链接,确保有一些预期的文本存在。但有时登录页面(https://library.med.nyu.edu/sso/ezproxy_form.php)出现在所需的页面之前,在这种情况下,我需要在检查页面之前登录。
问题是,无论我输入什么字符串来检查我是否登录页面,Selenium都认为它不存在并跳过登录,显然导致其他所有内容都失败。
见下文 - 我不确定这实际上是什么问题。它似乎是在没有实际登录的情况下冲过“如果我们需要登录”代码,然后明显地失败了测试的主要部分,因为它不在正确的页面上。selenium.waitForPageToLoad似乎并没有在等待
下面是代码 - 没有人看到我的错误吗?
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?");
}
}
你得到了什么确切的错误信息? – Feanor