disabled: comes out as "true" but needs to go in as "disabled" ?

16 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Andrew

nieprzeczytany,
3 sty 2012, 15:22:473.01.2012
do clj-we...@googlegroups.com
Firebug shows a particular element on my web page as this:

<input class="check-box" type="checkbox" disabled="disabled" checked="checked">

After finding the element as e...

(attribute e :disabled)
==> "true"

(find-it b {:disabled "true"})
==> #clj_webdriver.element.Element{:webelement nil}

(find-it b {:disabled "disabled"})
==> #clj_webdriver.element.Element{:webelement #<Tag: <input>, Class: check-box, Value: on, Object: org.openqa.selenium.firefox.FirefoxWebElement@ed559a89>}

(= e (find-it b {:disabled "disabled"}))
==> true

semperos

nieprzeczytany,
3 sty 2012, 19:34:433.01.2012
do clj-we...@googlegroups.com
Andrew,

This is accidental complexity introduced by Selenium-WebDriver. They explain that a number of attributes are treated as "boolean" attributes and thus return true/false as a "feature:"


Given that the value for these attributes is the same as the attribute name, and that I can only imagine checking if something is disabled or not (a boolean check), does it makes sense to "normalize" the `.getAttribute` method on the Clojure side by making something like `(attribute element :disabled)` return "disabled" (a truthy value) instead of "true" (also a truthy value)?

Your thoughts?

semperos

nieprzeczytany,
3 sty 2012, 19:38:063.01.2012
do clj-we...@googlegroups.com
Well, I take some of that back. If you asked `(attribute element :disabled)` on an element that is not disabled, you get "false" (the String "false"), which would be truthy value. That is wrong.

I'll make it consistent with other calls to `attribute`, and clj-webdriver will just have the burden of keeping the list of "boolean" attributes that we're normalizing up-to-date.

Thanks for catching this.

-Daniel

Andrew

nieprzeczytany,
4 sty 2012, 16:02:304.01.2012
do clj-we...@googlegroups.com
Thanks. I think the same thing might apply to :checked

semperos

nieprzeczytany,
4 sty 2012, 16:11:384.01.2012
do clj-we...@googlegroups.com
It does, and to many others:


The fix for this was added to the alpha3 release, give it a whirl.

-Daniel
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0