我正在更新一個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