WebDriver.FindElementByLinkTextファインドエレメントバイリンクテキスト メソッド

指定されたリンクテキストに一致する最初のWebElement オブジェクトを取得します。

構文
  1. WebElement = WebDriver.FindElementByLinkText( linktext, timeout, raise )
引数
linktext (String)必須
取得する要素のリンクテキスト
timeout (Long = -1)省略可
タイムアウト(単位:ms)。raiseTrueが指定されている場合、時間が過ぎるとエラーが発生します。
raise (Boolean = True)省略可
Trueのとき、タイムアウト経過後に例外を発生させる。
戻り値

使い方

リンクテキストがログインに一致する最初の要素をクリックします。まずクリックする要素のWebElement オブジェクトを取得し、WebDriver.FindElementByLinkText メソッドでその要素をクリックします。

UWSC
DIM WebElement = WebDriver.FindElementByLinkText("ログイン")
WebElement.Click()

Chromeでhttp://example.comを開き、リンクテキストがMore information...に一致する最初の要素をクリックします。

UWSC
DIM WebDriver = CREATEOLEOBJ("Selenium.WebDriver")

WITH WebDriver
	.Start("chrome")
	.Get("http://example.com")
	DIM WebElement = .FindElementByLinkText("More information...")
	WebElement.Click()
	SLEEP(5.000)
ENDWITH
HTML
<div>
    <h1>Example Domain</h1>
    <p>This domain is for use in illustrative examples in documents. You may use this
    domain in literature without prior coordination or asking for permission.</p>
    <p><a href="https://www.iana.org/domains/example">More information...</a></p>
</div>

この記事は役に立ちましたか?

はい
いいえ
ご協力ありがとうございます。