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

16 views
Skip to first unread message

Andrew

unread,
Jan 3, 2012, 3:22:47 PM1/3/12
to 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

unread,
Jan 3, 2012, 7:34:43 PM1/3/12
to 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

unread,
Jan 3, 2012, 7:38:06 PM1/3/12
to 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

unread,
Jan 4, 2012, 4:02:30 PM1/4/12
to clj-we...@googlegroups.com
Thanks. I think the same thing might apply to :checked

semperos

unread,
Jan 4, 2012, 4:11:38 PM1/4/12
to 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
Reply all
Reply to author
Forward
0 new messages