2014-05-06 11 views

risposta

13

Non è necessario chiamare click(). Basta trovare l'elemento e chiamare is_enabled() su di esso:

element = driver.find_element_by_name("sub_activate") 
print element.is_enabled() 

Cordiali saluti, click() è un metodo su un WebElement, restituisce None.

3

Si sta chiamando is_enabled() sul risultato click() (Nessuno).

Invece, si dovrebbe prima ottenere l'elemento, verificare se è is_enabled() quindi provare il click() (se è ciò che si sta tentando di fare).

Prendere un look at the docs per i metodi su webelement.

is_enabled() 
    Whether the element is enabled. 

click() 
    Clicks the element. 

Ad esempio:

elem = driver.find_element_by_id("myId") 
if elem.is_enabled(): 
    elem.click() 
else: 
    pass # whatever logic to handle... 
0
IWebElement button = driver.FindElement(By.Id("ButtonId")); 

Assert.AreEqual(false, button.Enabled); /*Validates whether the button is Disabled*/ 

Assert.AreEqual(true, button.Enabled); /*Validates whether the button is Enabled*/ 
Problemi correlati