2011-02-03 69 views
0

我用selenium ide和rc測試應用程序。我需要驗證鏈接。用getAllLinks檢查鏈接

通常我從Selenium ide導出文件到junit 4,並在eclipse中運行文件。文件爲下一個

package com.example.tests;

import com.thoughtworks.selenium。*; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.regex.Pattern;

公共類login_csupport延伸SeleneseTestCase { @Before 公共無效設定()拋出異常{ 硒=新DefaultSelenium( 「本地主機」,4444, 「*鉻」,「HTTP://daisy-w2003.hi。 INET/CustomerSupport「); selenium.start(); }

@Test 
public void testLogin_csupport() throws Exception { 
    selenium.open("http://daisy-w2003.hi.inet/CustomerSupport/?ReturnUrl=%2fCustomerSupport%2fAccount"); 
    assertEquals("Calling Cards Customer Support - Inicio", selenium.getTitle()); 
    selenium.type("UserName", "admin"); 
    selenium.type("Password", "admin"); 
    selenium.click("//div[@id='content']/div/form/div[3]/a/span[2]"); 
    selenium.waitForPageToLoad("30000"); 
    assertEquals("Calling Cards Customer Support - Gestión", selenium.getTitle()); 
} 

@After 
public void tearDown() throws Exception { 
    selenium.stop(); 
} 

} 使用getAllLinks我倒是像檢查頁面的鏈接。請,任何人都可以幫助我?

由於

回答

2

assertAllLinks(pattern)getAllLinks()

Returns: 
the IDs of all links on the page 

Returns the IDs of all links on the page. 

If a given link has no ID, it will appear as "" in this array. 
產生