import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class firefoxTest {
public static void main(String[] args) {
WebDriver driver = new HtmlUnitDriver();
// URLを開く
driver.get("http://127.0.0.1/~yamato/fx7/WebDriverTest/index.html");
// Aタグを取得
List<WebElement> cheese = driver.findElements(By.tagName("a"));
// 取得した要素の0番目のリンクアドレス
System.out.println(cheese.get(0).getAttribute("href"));
// 取得した要素の0番目のリンクテキスト
System.out.println(cheese.get(0).getText());
}
}
2012年5月17日木曜日
WebDriver:ページのリンクを取得する
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿