I want to know what is the correct way to change any attribute value of an element in geb (selenium).
For example, I have this element:
static content = {
radioSelect(wait: true) { $('input[name=rr]')}
}
Now I want to set any attribute. I did not found a good method, I use this workaround:
(driver as JavascriptExecutor).executeScript( "document.getElementsByName('rr')[0].setAttribute('checked', true)" )
Is there another way? Like radioSelect.setAttribute?
Use the jQuery integration offered by Geb:
radioSelect.jquery.attr("checked", true)
This is the equivalent of
js.exec 'jQuery("input[name=rr]").attr("checked", true)'
But be careful:
The jQuery integration only works when the pages you are working with include jQuery, Geb does not install it in the page for you. The minimum supported version of jQuery is 1.4.