它已經很長一段時間:-)硒RC的getTitle方法
我還是用我的硒RC的學習,我使用www.irishtimes.com作爲我測試的應用程序。
我有一個包含這些步驟一個非常小的測試案例:
硒硒;
public void setUp() throws Exception {
super.setUp();
selenium = new DefaultSelenium("localhost",
SELENIUM_PORT,
"*firefox",
"http://www.irishtimes.com/");
setUp("http://www.irishtimes.com/", "*firefox");
}
public void testTCNewspapers() throws Exception {
selenium.start();
selenium.open("http://www.irishtimes.com/");
selenium.waitForPageToLoad("30000");
selenium.click("link=Life");
//Doesn't work
//verifyEquals("The Irish Times - Life", sel.getTitle());
}
當執行verifyEquals我得到這個錯誤:
java.lang.AssertionError: java.lang.AssertionError: Expected "The Irish Times - Life" but saw "The Irish Times – Irish News, Business News, Sports News & Ireland Weather Online" instead
在com.thoughtworks.selenium.SeleneseTestBase.fail(SeleneseTestBase.java:356)
我不明白爲什麼會發生這種情況,因爲頁面的標題是「愛爾蘭時報 - 生活」
從源頭HTML文件:
<title>The Irish Times - Life</title>
上解決這個任何幫助嗎?謝謝;-)
感謝。由於DefaultSelenium類中沒有clickAndWait方法,因此我使用了waitPageToLoad(「30000」)方法 – Panacea 2010-12-13 16:38:32