1

I'm trying with Selenium IDE and Selenium IDE++ (Kantu) 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 either Selenium IDE or 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">

Below I show an example of this:

function myFunction() {
  document.getElementById("abc").disabled = true;
}
<!DOCTYPE html>
<html>
<body>

Name: <input id="abc" class="form-control input">

<p>Click the button to disable the text field.</p>

<button onclick="myFunction()">Disable Text field</button>

</body>
</html>

Thanks for any help.

Ger Cas
  • 1,750
  • 1
  • 10
  • 28
  • 1
    Can you tell more about the website you need to use this on? When I use exactly your provided HTML and JS code as a mockup, your first StoreValue attempt works for me in Kantu. – Pinkie Pie Jul 07 '19 at 07:15
  • @PinkiePie Hello, I've tried with the URL of this post with Kantu. I recorded a macro and click on the disabled text and was recorded as `id=abc`. Then I tried with `storeValue|id=abc|var` and when I run it I get `timeout reached when looking for element 'id=abc'` May you share your commands to see how it worked for you please. – Ger Cas Jul 07 '19 at 15:38
  • 1
    I used precisely the code you posted in the question in the first code block, the html just the same too with the function inside a tag. If you try it here on the "Run code snippet" window then it fails because that's inside an iframe. If you try to get the element by id in the browser console it will fail, too. That's why the site you want to run this on is important, is the field you need to read inside an iframe there as well? If that's so, read this on how to access data inside the iframe https://stackoverflow.com/questions/1088544/get-element-from-within-an-iframe – Pinkie Pie Jul 08 '19 at 06:30

0 Answers0