I tried below code but not works.
a = WebUI.executeJavaScript('document.getElementsByTagName("input")[29].value', null)
Thread.sleep(5000)
System.out.println(a)
I tried below code but not works.
a = WebUI.executeJavaScript('document.getElementsByTagName("input")[29].value', null)
Thread.sleep(5000)
System.out.println(a)
Copyright © 2021 Jogjafile Inc.
There is so much wrong with this question that I don't even know where to begin...
What are you trying to accomplish by using JavaScript (this is a testing code smell, for 99% of testing cases) to fetch a
value?Why not do the following:
TestObject, preferably in the Object Repository, that points to the object in question.In your case, give it xpath
(//input)[29]. However, I advise you come up with a more meaningful selector for it (for example, select it by some
class,data-*attribute,name) that is easier to maintainWebUI.getAttribute(findTestObject('[whateverYourTestObjectNameIs]'), 'value')Also, why are you pausing runtime by some hard-coded time amount? That is a testing code smell. Stop it!
What exactly are you waiting on? Use the
WebUIkeywords for this thing you are waiting on, and if none of those suffice, hmu and I may have the wait method you're looking for ....Oh, and looking at that image you linked, it looks like you solved your own question.