0
<input class="form-control ng-pristine ng-empty ng-invalid ng-invalid-required ng-touched" type="number" access-control="create_rate" ng-disabled="vm.state.disabled" required="required" name="amount" ng-model="vm.rate.user_amount"/>

I have used:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].removeAttribute('disabled')", merchantRate.addNewRatesCashback);
merchantRate.addNewRatesCashback.sendKeys(rate);

But I got an error saying removeAttribute can't be identified.

Can anyone please help me to send text into the disabled field using java/javascript.

1
  • Why are you having to remove this? If this is a functional test, it seems a little odd that you have to do this . . .
    – ernie
    Commented May 8, 2017 at 19:42

1 Answer 1

2

It looks like your code is looking for an attribute disabled (which your form field doesn't have) - it's looking for

<input type=text value="Some text" disabled />

What you need to do is remove the attribute ng-disabled which your form field does have.

That should be enough to allow you to enter text into the field.

2
  • Hi Kate thanks for you reply, i changed to ng-disabled but i got an error as " org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@class='form-body']/div[3]/div[1]/input[@name='amount']"}" but i can see in the DoM/firefinder the xpath is correct and i can find the element Commented May 8, 2017 at 12:30
  • Hi Kate done the changes as suggested and it is working fine now, thank you so much :) Commented May 8, 2017 at 12:36

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.