0
data-ng-disabled="disableUpload"

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

@FindBy(xpath="//button[@id='createMoreButtonAs22'][@data-ng-disabled='disableUpload']")

or

@FindBy(xpath="//*[@id='createMoreButtonAs22']/i")

function

public void addFiles() throws InterruptedException { 

    WebDriverWait wait = new WebDriverWait(driver, 60);

    wait.until(ExpectedConditions.elementToBeClickable(addfilebtn));

    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 Jun 25 at 19:15
  • Thanks for the review. I have edited the post for more clarification – RinJai Jun 26 at 1:43
  • Now its working :) I gave the ID of the element and enabled it .. – RinJai Jun 26 at 2:00
0

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

| improve this answer | |

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.