Error when trying to storeValue from input disabled text

Hello to all,

I’m trying with to store the text from an input element with text disabled.

I tried:

StoreValue|id=abc|var1
echo      |${var1}|

But I get error [error] timeout reached when looking for element 'id=abc'

Then I’ve tried with javascript with this code:

document.getElementById("abc").value

And when I tried that JS code in Chrome console it works and prints the text I want, but if I insert this code in Kantu doesn’t work. I do like this:

executeScript|var a = document.getElementById("abc").value; return a;| var1
echo         | ${var1}

In this case I get error Error in executeScript code: Cannot read property 'value' of null

When I inspect with Developer tools in chorme the text I want to get, the code is like this:

<input id="abc" class="form-control input" disabled="disabled">

You can run the example here Edit fiddle - JSFiddle - Code Playground . Just run it, write some text and click on button “Disable text field”. The text you write there is what I want to store in a variable.

I asked in SO forum but I still don´t have a solution.

Thanks for any help.

Is the text in the page source code?

If so, you can try to you use sourceExtract:

sourceExtract works with the page source code instead of looking at the web page object model (DOM) that all other “classic” Selenium IDE command use. Thus sourceExtract can extract e. g. comments in the page source code and can check/extract Javascript code parts (like the Google Analytics ID) that are invisible to a command like storeText.

Hi Timo,

The text is not in the source code. You can check the example here Edit fiddle - JSFiddle - Code Playground

Is an input element, you write some text and then click on “Disable text field”. You’ll see is not in the HTML source code.

Thanks.

It works for me with the test website, here is my macro:

(maybe selectFrame was missing in your test?)

{
  "Name": "disabled",
  "CreationDate": "2019-7-9",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://jsfiddle.net/of9w7pmt/",
      "Value": ""
    },
    {
      "Command": "selectFrame",
      "Target": "index=0",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "id=abc",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=abc",
      "Value": "12345678"
    },
    {
      "Command": "click",
      "Target": "xpath=/html/body/button",
      "Value": ""
    },
    {
      "Command": "storeValue",
      "Target": "id=abc",
      "Value": "var1"
    },
    {
      "Command": "echo",
      "Target": "var1=${var1}",
      "Value": "blue"
    }
  ]
}
1 Like

Hi Howard, thanks so much for your help. Yes, it seems it was missing select the frame before the storeValue command. Now it works!