Finding out if a given selector (XPATH, ID or Whatever) is Enabled in Selenium
I just spent a whole day trying to figure out how to define if a given element (defined using an xpath) is an enabled (i.e. not disabled) element in "Selenese", using Python bindings.
Finally cracked it:
def is_element_enabled(self, element):
script = """this.page().findElement("%s").disabled;"""
script_return = self.selenium.get_eval(script % element)
if script_return == "null":
is_disabled = self.__get_attribute_value(element, "disabled")
else:
is_disabled = script_return[0].upper()=="T"
return not is_disabled
I know it's not pretty but after that many hours I DON'T CARE! I'm hoping someone will come and say: "There's a much easier way of doing that. Just use xxx" and then I'll fix it. For the time being it stays.
BTW http://www.pyccuracy.org is up and running and Pyccuracy got it's 0.3.1 release already.
Cheers,