1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

XPathでチェックボックスやラジオボタンにチェックをいれる

Last updated at Posted at 2018-10-23

xpath職人のものを参考にしたり、調べたりして作った。

こういうinputタグがあったとして、

<input type="text" id="your_name" name="your_name" maxlength="40" value>
<input type="text" id="your_email" name="your_email" maxlength="40" value>
<input type="checkbox" id="your_checkbox" name="your_checkbox" value>
<input type="radiobox" id="your_radiobox" name="your_radiobox" value>

ブラウザのコンソールを開いて以下を入力して、Enterを押すと
フォームに値が入ったり、チェックボックスやラジオボックスにチェックが入ったりします。

$x('//*[@id="your_name"]')[0].value = 'あなたのなまえ';
$x('//*[@id="your_email"]')[0].value = 'youremail@xxx.co.jp';
$x('//*[@id="your_checkbox"]')[0]["checked"]= 'true';
$x('//*[@id="your_radiobox"]')[0]["checked"]= 'true';
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?