現在フォーカスがあるアクティブな要素を返します。
- 構文
- WebElement = WebDriver.ActiveElement( )
- 引数
- 戻り値
使い方
アクティブ要素に文字列を入力
https://google.co.jpを開き、フォーカスがある要素にUWSCと入力します。
DIM WebDriver = CREATEOLEOBJ("Selenium.WebDriver")
WITH WebDriver
.Start("chrome")
.Get("https://google.co.jp")
DIM WebElement = .ActiveElement
WebElement.SendKeys("UWSC")
.Wait(5000)
ENDWITH
- 結果
アクティブ要素の内容を取得
アクティブな要素(body,input,select,textarea,buttonのいずれか)が吹き出しに表示されます。
SETHOTKEY(VK_ESC, EMPTYPARAM, "forceQuit")
DIM driver = CREATEOLEOBJ("Selenium.WebDriver")
driver.Start("chrome")
driver.Get("D:\Desktop\index.html")
WHILE TRUE
DIM WebElement = driver.ActiveElement()
FUKIDASI(WebElement.tagname)
SLEEP(0.001)
WEND
//////////////////////////////////////////////////
// 【引数】
//
// 【戻り値】
//
//////////////////////////////////////////////////
PROCEDURE forceQuit()
EXITEXIT
FEND
<html>
<head>
<style>
<!--
label{display:block;}
textarea{width:300px; height:200px;}
-->
</style>
</head>
<body>
<form>
<label>ユーザー名:
<input type="text" name="username" />
</label>
<label>パスワード:
<input type="text" name="password" />
</label>
<label>性別:
<select>
<option value="male">男</option>
<option value="female">女</option>
</select>
</label>
<label>備考:
<textarea></textarea>
</label>
<button type="button">送信</button>
</form>
</body>
</html>
この記事は役に立ちましたか?
ご協力ありがとうございます。