htmlselenium-webdriverdomautomationprotractor

How to get the value of Element that is Disabled and not present in DOM


I am using Protractor for Automation. I am trying to verify value of element present in the model window. the element is disabled (greyed out) and not present on the DOM. How to get the value of this element?

I tried out Javascript Executor

  1. broswer.executeScript("return arguments[0].value", webElement); //Failed: javascript error: Cannot read properties of null (reading 'value')
  2. webelement.getAttribute('innerHTML')// Failed: Cannot read property 'getAttribute' of undefined
  3. webelement.getAttribute('value') //Failed: Cannot read property 'getAttribute' of undefined
  4. From the Link Need to get the value which is not available in DOM element I tried out document.getElementByClass('uk-input uk-margin-remove au-target').value --//this also gives undefined

When we hover on the value it is shown in this below line :

<input disabled="disabled" type="text" class="uk-input uk-margin-remove au-target" value.bind="model.mof.offer_code" au-target-id="2588" placeholder="(Undefined)">

enter image description here

I want to fetch 234218 value from the UI. Is there any way I can get the element value?


Solution

  • run this following javascript,

    broswer.executeScript("arguments[0].removeAttribute("disabled")", webElement);
    

    And verify