Closed vveliev closed 7 years ago
Very interesting. Can you show me the html that you are having an issue with?
Here is the part of the HTML
<div class="selectMenu">
<select id="select-perPage">
<option value="10">
10
</option>
<option value="25" selected="selected">
25
</option>
<option value="50">
50
</option>
<option value="100">
100
</option>
<option value="250">
250
</option>
<option value="500">
500
</option>
</select>
</div>
@titusfortner any updates ?!
@vveliev - Can you try this with the latest code and see if it is still an issue? You can select by value in Watir, which page-object should be wrapping now.
yes that's why there is a pull (#415) request, but I have not checked if list.select('value')
works, but page_populate_with
does not support values (just does not select any option keeps default and no error.)
Let's discuss it here , rather than in pr,
From my experience value fro the option been more consistent across browsers rather then exact text match. There have been inconsistency in text between firefox and chrome, so all my data is based on values.
At this moment populate_page_with
not working for me , so you may have select by value in watir, it's not by default or by configuration. When I started working with page object , I also found it was hard to work with text , because some times it's just big sentences that looked bulky compare to single word values.
But ones again from my experience i'm more biased towards select by value rather then text. And I think populate_page_with
should have ability to select options by other attributes then only by text, how it's will be implemented if it will be implemented , is something we can discuss.
Ok I see; you want this to work automatically with #populate_page_with
.
Right now you can use #populate_page_with
to select an option from a select list by text, correct? Wouldn't your PR would override that and force it to select by value?
no , my PR first check's if there is a text value that it can much , if not it will try to use value , It should be backwards compatible ;) ...
Hmm, can't say I see what is going on without running tests against it, but can't you just do something like:
select_element = self.send(“#{key}_element”)
if select_element.include?(value)
select_element.select(value)
else
select_element.select_value(value)
end
yes this may work...
def populate_select_list(key, value)
select_element = self.send(“#{key}_element”)
if select_element.options.include?(value)
select_element.select(value)
else
select_element.select_value(value)
end
end
but if you are planing to use values for select list, why not change select , so that it would be identical to the what populate will do .
This is a part of automatically populating a field, not a matter of how to select the field. Unless Watir decides it should implement a "universal" setter for methods, I think the correct purview for the code is in a page object gem.
@vveliev hey, also wanted to make sure you knew about the Watir/Ruby Selenium channels in the Selenium Slack. Come and join in the conversations: http://seleniumhq.herokuapp.com/
I think we can close this one.
I have run into the problem where my code does fork in FF and does not in Chrome.
What I have noticed that in different cases page rendered differently in different browser. The problem that I have discovered, that
select_list.options
can be different based on the browser.FF:
["10", "25", "50", "100", "250", "500"]
Chrome:[" 10\n ", " 25\n ", " 50\n ", " 100\n ", " 250\n ", " 500\n "]
I think it should use
element.attribute(:value)
insteadelement.text