したがって、ページには次のコードがあります。
<div class="toggle-wrapper">
<input id="HasRegistration_true" class="registration_required toggle" type="radio" value="True" name="HasRegistration" data-val-required="The HasRegistration field is required." data-val="true">
<label for="HasRegistration_true" class="">On</label>
<input id="HasRegistration_false" class="registration_required toggle" type="radio" value="False" name="HasRegistration" checked="checked">
<label class="checked" for="HasRegistration_false">Off</label>
</div>
これらは 2 つのラジオ ボタンです。'オンとオフ'。「オフ」がデフォルト値です。
Watir-webdriver と Ruby を使用して、「オン」ラジオ ボタンを選択します。次のようにします。
browser.radio(:id => "HasRegistration_true").set
しかし、そうすると、次のエラーが発生します。
`WebElement.clickElement': Element cannot be scrolled into view:[object HTMLInputElement] (Selenium::WebDriver::Error::MoveTargetOutOfBoundsError)
Selenium 2 はページを要素までスクロールすることがわかっているため、下にスクロールしようとしても無駄です。私たちは常にwatir-webdriverとrubyの最新リリースを使用しています。
私たちは QA エンジニアであるため、ページの HTML を変更することはできません。