-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow all form field types to be called using 1 element type: browser.form_field #664
Comments
This might dovetail with #405. What if we define set method on input class, lookup the type and take the action on an object of that subtype. |
@titusfortner, are you suggesting that someone would use |
Oh right... I guess |
I was thinking in the line of: def form_field(args*)
case args
when b.input(args).exists?
return b.input(args)
when b.select(args).exists?
return b.select(args)
when b.text_area(args).exists?
return b.text_area(args)
else
raise Watir::ElementNotFoundError
end
end Or maybe, to reduce redundancy, make an array with form_field_types |
The intention is to make it so you don't have to specify the element type or figure out the appropriate input method? What if instead of adding another method, we just duck type it? Everything that responds to def set(*args)
return to_subtype.set(*args) if self.instance_of?(Watir::Element)
raise "#{self.class} does not support the #set method"
end This would have the advantage of making Page Object implementations easier. This could also make it easier to implement select list type behavior for weird divs that some devs like to do by simply adding a |
Hmm, though this wouldn't work for the |
To solve the # element(selectors).set(value)
if element.type == 'radio' and value.is_a? String
browser.input(selectors, :value => value).set
end Maybe this could actually be implemented in the |
…g for all element types for watir#664
…g for all element types for watir#664
…g for all element types for watir#664
This was implemented and will be available in 7.0.0.beta2 |
Cool stuff, thanks @titusfortner ! |
Only took, what, 3 1/2 years? :) |
As requested by Titus, putting a ticket in for a possible new feature.
In the category "thinking out loud": I've been working the last few weeks on quite some form validation scripts, creating my own custom form_field_to_value functions and it made me wonder. Could we make (or is there already) a selector that groups
input
,select
&textfield
into 1 selector:form_field
. In practise making it look something as following.Expected Behavior -
This would make it much easier to convert configuration values to actual form input values, without having to worry about which element type you're trying to set.
The text was updated successfully, but these errors were encountered: