How to work with such attribute?

I will elaborate more on this,

I want to upload a file by clicking on the + icon near add file button, but the below code says its disabled.

The code snippet is

enter image description here

I gave the xpath as below but nothing is working out .Please assist





public void addFiles() throws InterruptedException { 

    WebDriverWait wait = new WebDriverWait(driver, 60);


    boolean flag = addfilebtn.isEnabled();
    if (flag) {

        ((JavascriptExecutor) driver).executeScript("arguments[0].click();", addfilebtn);

        System.out.println("After clicking");

    } else
        System.out.println("Element cannot be clickable");


but still not working. How to click the button so that file can be uploaded?

  • It's not very clear what you are asking. If the button is disabled, you won't be able to click it. It will need to be enabled first. Are you asking how to enable it before clicking it? Or is it currently enabled and you want to disable it? There's not enough information. The current code snippet doesn't show "createMoreButtonAs22" or "data-ng-disabled="disableUpload", can you add the relevant code/DOM?
    – Lee Jensen
    Commented Jun 25, 2020 at 19:15
  • Thanks for the review. I have edited the post for more clarification
    – RinJai
    Commented Jun 26, 2020 at 1:43
  • Now its working :) I gave the ID of the element and enabled it ..
    – RinJai
    Commented Jun 26, 2020 at 2:00

1 Answer 1


Try using just //button[@id='createMoreButtonAs22'].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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