我在Selenium RC中遇到了一個奇怪的問題。當我使用IE7時,測試工作正常。但是,如果我使用Firefox 3.5,Selenium會在完全加載之前提取頁面。使用線程睡眠可以解決此問題。在Selenium RC中加載FireFox和IE的頁面
頁面加載標誌如何處理IE和FireFox之間有區別嗎?
selenium.setTimeout(Timeout);
selenium.open("http://localhost");
selenium.waitForPageToLoad(Timeout);
selenium.windowMaximize();
selenium.windowFocus();
Thread.sleep(60000);
selenium.type("//html/body/table/tbody/tr[2]/td/div/form/table/tbody/tr[1]/td/table/tbody/tr[3]/td[2]/input","test");
selenium.type("pwd","test");
selenium.click("submit");
selenium.waitForPageToLoad(Timeout);
Thread.sleep(60000);
System.out.println(selenium.getLocation());
System.out.println(selenium.getHtmlSource());
String[] ro=selenium.getAllLinks();
System.out.println("-----"+ro.length);
在IE7中,一切適用thread.sleep,而不是在FireFox中。
你的例子有兩個睡,如果是去掉其中一個導致Firefox的一個問題?另外,您從Selenium獲取什麼錯誤? – 2010-05-25 11:44:04
如果我刪除睡眠,硒沒有找到FireFox中的元素。沒有其他的。 – Rajasankar 2010-05-25 12:13:59
因此,這將是第一次睡眠,然後你會得到一個ElementNotFoundException? – 2010-05-25 12:19:25