Вопрос

I have a checkbox as follows:

<input type="checkbox" value="true" name="replaceExisting"></input>

Unfortunately, the following code is NOT causing the checkbox to get checked:

$('checkbox', name:'replaceExisting').value('true')

Any ideas?

Это было полезно?

Решение

The Geb docs on checkboxes are wrong:

    // in the docs; doesn't work.
    $('checkbox', name:'replaceExisting').value('true')

    // This works:
    $('input', type:'checkbox', name:'replaceExisting').value('true')

    // This works, too:
    $('input', name:'replaceExisting').value('true')

Другие советы

As a work around, this works for setting the checkbox on:

js.exec("document.getElementsByName('replaceExisting')[0].checked = true");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top