I am trying to automate react native android application, but I am not able to click on the button whose property is clickable=false.

This is my code, please help me


I would have thought that is the correct behaviour.

In your browser, if something is clickable, then you can click it. If it is not clickable, then you can't. Selenium acts as a browser. No different.

IMHO, the question you should be asking yourself should be why is the button disabled? It might be a valid state, e.g. a submit button might be disabled until user name and password fields are completed.

  • No actually button is not disabled..if i am tapping manually it works but on scripting it is not working
    – ajinkya
    Oct 10 '17 at 11:16
  • OK, have you tried inspecting the element? By that I mean assigning it to a var and then seeing what is insdie, before trying to click it. E.g. var WebElement myVar = driver.findElement(By.xpath("//android.view.ViewGroup[@index='2']/android.widget.Button[@index='2']")) Oct 10 '17 at 11:31
  • By checking the properties of the element, you might be able to see why you cannot click on it. A first port of call for me would be displayed and enabled properties. After that, I'd look at the attribute property. Oct 10 '17 at 11:33

Give this a go, build up the action:

private static void actionClick(WebElement e)
    Action b = new Actions(driver).moveToElement(e).click().build();

Could also try sending an ENTER onto the button after you move to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.