Closed TylerRick closed 5 years ago
Using element.native
for normal things is generally a bad idea - since it makes your tests driver specific. Also the way you're writing your helpers is going to produce race conditions. You'll be much better off just using the CSS pseudo selectors :valid
and :invalid
-
def expect_valid(element)
expect(element).to match_css('*:valid')
end
As to why it always returns nil for this - it's because validity returns a ValidityState
object which Apparition doesn't know how to deal with, I need to look at that.
Fixed nil response via 72233c0262f6430caf88fbfea643c6ae32ea017f - however you're still going to be better off longterm just using the :valid
/:invalid
CSS pseudo selectors rather than directly accessing the validity
property.
Also, the next Capybara release will have a :valid
node filter option on the :field and :fillable_field selectors
When using a Selenium driver, I'm able to check the validity state of an input with
element.native.property(:validity)
. But with Apparition driver,property(:validity)
always returns nil. Why is that? And can it be fixed?Example
As an example, I have an input in my tests that I wanted to test transitioned from
"valid"=>false
to"valid"=>true
after changing the input in a certain way.This is what it returned when it was invalid:
This is what it returned when it was invalid:
I can't figure out how to do this with apparition since it always returns nil.
validationMessage
property is availableInterestingly, I noticed that the
validationMessage
property is available for the same element, so as a workaround I was able to check whethervalidationMessage
waspresent?
or not (seems to return "" when input is valid).I'm curious why apparition has is able to get
validationMessage
but notvalidity
. In the developer tools console, you can see that the validity property does exist and is not null.Some related test helpers