cheezy / page-object

Gem to implement PageObject pattern in watir-webdriver and selenium-webdriver
MIT License
653 stars 220 forks source link

Select_list will not select. I can't see what but this hack works #420

Closed Githraine closed 7 years ago

Githraine commented 7 years ago

Here is the HTML:

<select class="child-count form-control">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
</select>

All of the normal methods to select an option did not work. This code finally worked:

  def select_option(object, value)
    index = 0
    self.send("#{object}_options").each do |item|
      if item == value
        self.send("#{object}_element").options[index].click
      else
        index += 1
      end
    end
  end

I tried: self.send("#{elem_name}=", value) and self.retire_at_age='68' and several other permutations

vveliev commented 7 years ago

did you tried :

select_list(:child_list, class: 'child-count')

#option1
child_list_element.select('2')

#option2
self.child_list='2'
Githraine commented 7 years ago

self.retire_at_age='68' Yes.

joesho112358 commented 7 years ago

@Githraine I would benefit from having the page definitions supplied along with the specific calls and responses; otherwise, it would be a bit of a guessing game. Could you supply those?

AlexisKAndersen commented 7 years ago

@Githraine, if you're still experiencing this issue, please feel free to add details about the code and error messages you're getting, and reopen