LoginSignup
7

More than 5 years have passed since last update.

posted at

PHPUnit_Extensions_Selenium2TestCase での各種HTML操作

リンクをクリック

サンプルHTML

<a href="">link_text</a>

テストケース

$this->byXPath("//a[text() = 'link_text']")->click();

ボタンクリック

サンプルHTML

<input type="button" value="button_text" id="button_id" >

テストケース

$this->byXPath("//input[@value = 'button_text']")->click();
$this->byCssSelector("#button_id")->click();

テキストボックスに入力

サンプルHTML

<input type="text" name="text_name" >

テストケース

$this->byName('text_name')->value($user);

セレクトボックスから選択

サンプルHTML

<select name="select_name">
<option value="option_value1" >option_text1
<option value="option_value2" >option_text2
</select>

テストケース

$this->select($this->byName("select_name"))->selectOptionByValue("option_value2");

ラジオボタンから選択

サンプルHTML

<input type="radio" name="radio_name1" value="radio_value1" >radio_text1
<input type="radio" name="radio_name2" value="radio_value2" >radio_text2

テストケース

$this->byXPath("//input[@value = 'radio_value1']")->click();

フォームのsubmit

サンプルHTML

<form action="#" method="post">
<input type="submit" value="submit_value">
</form>

テストケース

$this->byCssSelector("form")->submit();

TODO

徐々に追加予定
ラップが薄すぎて辛い

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
What you can do with signing up
7