2016-04-14 7 views
0

geb(セレン)の要素の属性値を変更する正しい方法は何ですか。Gebが属性値を変更しています

例えば、私は、この要素を持っている:

static content = { 
    radioSelect(wait: true) { $('input[name=rr]')} 
} 

は今、私は任意の属性を設定します。私は良い方法が見つからなかった、私はこの回避策を使用します:

(driver as JavascriptExecutor).executeScript("document.getElementsByName('rr')[0].setAttribute('checked', true)") 

別の方法がありますか? radioSelect.setAttributeと同様?

答えて

2

はゲブが提供するjQuery integrationを使用します。

radioSelect.jquery.attr("checked", true) 

これは

js.exec 'jQuery("input[name=rr]").attr("checked", true)' 

のと同じですしかし、注意してください:

ページはあなたがあるときにjQueryの統合のみ動作します jQueryが含まれていると、Gebはあなたのページにそれをインストールしません。 のjQueryの最小サポートバージョンは1.4です。