wait for element to be clickable/not disabled/not greyed out in Python (expected conditions)

1,122 views
Skip to first unread message

cmt2012

unread,
Sep 17, 2012, 3:41:44 PM9/17/12
to seleniu...@googlegroups.com
hi all,

first, i fear the answer to my question is already no, as it looks like from here that this functionality is not yet ported to python, but wanted to check in in case anyone knows of a workaround.

essentially, i'm trying to come up with a wait command in python that checks an element, in this case, a submit button, is clickable/enabled/not greyed out. the standard webdriverwait doesn't appear to work because the element is always visible, but not always clickable. i've played around with this getattribute function a bit that i found online too, but (probably due to not understanding how to use it fully) haven't gotten it to work. 

could anyone provide some helpful hints? i don't know if this will help, but the relevant portions of the source code of the website i'm testing on is below:

<input type="button" value="Submit" id="SubET" onclick="TabScript.saveSelections();" />
...
 
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(function() {
   $(' SubET ').disabled = true;
});
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() {
   $(' SubET ').disabled = false;


cmt2012

unread,
Sep 17, 2012, 3:43:47 PM9/17/12
to seleniu...@googlegroups.com
oh, also, the official site provides some other reference for what i'm asking:


Expected Conditions

There are some common conditions that are frequently come across when automating web browsers. Listed below are Implementations of each. Java happens to have convienence methods so you don’t have to code an ExpectedCondition class yourself or create your own utility package for them.

  • Element is Clickable - it is Displayed and Enabled.
wait = WebDriverWait(driver, 10)
def clickable(element):
  if element.is_clickable():
    return element
  return null
element = wait.until(lambda d: clickable(d.find_element_by_id('someid')))

The ExpectedConditions class in contains a set of predefined conditions to use with WebDriverWait in Java.

unfortunately, the code they give for python that i pasted in doesn't actually work, as "clickable" is not recognized. not sure what i'm doing wrong??
Reply all
Reply to author
Forward
0 new messages