1

4 つのラジオ ボタンがあります。

<div class="x1-radio">
    <input id = " " type="radio" name=" " value="12345">
        <span class=" ">Radio 1 - Good Luck</span>
<div class="x1-radio">
    <input id = " " type="radio" name=" " value="12345">
        <span class=" ">Radio 2 - Good Luck</span>
<div class="x1-radio">
    <input id = " " type="radio" name=" " value="12346">
        <span class=" ">Radio 3 - Good Luck</span>
<div class="x1-radio">
    <input id = " " type="radio" name=" " value="12347">
        <span class=" ">Radio 4 - Good Luck</span>

これらはラジオ ボタンなので、一度に 1 つ選択できます。xpathを使用してラジオボタンを選択する方法を知っています:

nPath = '//*[@class="x1-radio"]//span[text() = "Radio 1 - Good Luck"]'
browser.element(:xpath, nPath).fire_event "onclick"

この時点でボタンが選択されています。私が知りたいのは、「input」タグの属性を1つずつ画面に表示する方法です。

私はここでいくつかの情報を見つけました: How can I get value of element custom attribute with Watir but could not do it.

4

1 に答える 1

2

これにより、各要素のvalue属性の値が表示されます。input

browser.inputs.each {|input| p input.value}

このようなものは、同じ情報を表示する必要がありますが、選択したラジオ ボタンに対してのみ表示されます。

browser.inputs.each {|input| p input.value if input.checked}
于 2013-03-14T16:00:37.467 に答える