teodesian / Selenium-Remote-Driver

Perl Bindings to the Selenium Webdriver server
174 stars 90 forks source link

Allow ability to not emulate JSONWire behaviors in WC3 backed methods such as getAttribute #376

Closed ylavoie closed 6 years ago

ylavoie commented 6 years ago

The current implementation of get_attribute tries WebElement properties first but returns immediately for browsers other than chrome and MicrosoftEdge, without trying to get the WebElement attributes.

teodesian commented 6 years ago

What it does is laid out in the POD:

In older webDriver, this actually got the value of an element's property. If you want to get the initial condition (e.g. the values in the tag hardcoded in HTML), pass 1 as the second argument. This can only done on WebDriver 3 enabled servers.

It deliberately tries to get properties first unless you ask it to as a compatibility measure (get_attribute used to get properties, not attributes). I figured this would be fine given in old web driver there was no way to get the actual properties without execute_script.

ylavoie commented 6 years ago

Agreed but it only gets the properties, never the attributes. For a wd3 Firefox without the compatibility flag, get_attribute should only get attribute and get_property the property, no? With the current implementation, both will target the properties and never the attributes.

teodesian commented 6 years ago

not 'never'. It will give you the attributes if you pass 1 as the second arg. If it isn't that's the real bug here.

Perhaps what might satisfy your use case would be some global switch to turn off the fallback to legacy behavior?

ylavoie commented 6 years ago

I switched to compatibility mode for the moment. But my feeling is that we emulate wd2 with that and wd3 is moving away from that behaviour, thus my question about how to get attributes with Firefox without the compatibility flag. If we don't use the flag, both routines only returns properties with firefox.

teodesian commented 6 years ago

Ahh, so you are wondering whether we want to act like the spec in the future rather than emulating the old (misleading) behavior. I see your point there, but until things stabilize and all the modern drivers support these methods I'm not quite sold on going this route.

The goal with the WD3 conversion was to (try) not to break people's assumptions and thus require test changes as much as I could. At some point in the future that stops being a problem though; I'm not sure we're quite there yet.

As is, I've still broke a number of things accidentally with various setups and I'd like for things to get stable for a bit before I break people's tests deliberately. I'll back-burner this until I'm ready to make breaking changes.

teodesian commented 6 years ago

That said, to accomodate you, I can throw in an extra global flag in the meantime to sort of disable these kind of weird shims making WC3 act like JSONWire (there are a few others too). I'll look at that this weekend.