Reputation: 572
Below is the code, that describes the radio button elements.
<div class="questionnaire_detail_question_body">
<div class="questionnaire_detail_answers">
<label class="radioinputwrapper">
<input class="questionnaire_detail_radiobutton" type="RADIO" value="Never">
</label>
<label class="radioinputwrapper">
<input class="questionnaire_detail_radiobutton" type="RADIO" value="Sometimes">
</label>
<label class="radioinputwrapper">
<input class="questionnaire_detail_radiobutton" type="RADIO" value="Often">
</label>
</div>
</div>
I tried getting all the radio button under particular div and selected the option using the below code. Item is the list element to iterate over this
answers = item.div_element(class: 'questionnaire_detail_question_body')
.div_element(class: 'questionnaire_detail_answers').radio_button_elements
answers.each do |input|
if input.value.include? option
input.click
selected_option &&= input.set?
end
end
But while validating, whether the radio button is check or not using .set? or .checked?, I'm getting deprecation warning as
* DEPRECATION WARNING You are calling a method named set? at psc.rb:62:in `block (2 levels) in psc_choose_selected_score'. This method does not exist in page-object so it is being passed to the driver. This feature will be removed in the near future. Please change your code to call the correct page-object method. * If you are using functionality that does not exist in page-object please request it be added.
I tried using the methods mentioned in https://github.com/cheezy/page-object/wiki/Elements, as select_option and option_selected?
My question is how to get rid of this deprecation warning?
Upvotes: 1
Views: 323
Reputation: 46846
The method for checking that a
PageObject::Elements::RadioButton
is selected is selected?
:
input.selected?
Upvotes: 1