Dynamic Attribute Search Element

Trying to find the value of an element

"QNTAnswer" : self.page.find("input[chkid='"+res[i]+"']").val(),

doesn't work but if i hardcode value like

"QNTQuestionComments" : self.page.find("textarea[chkid='1-IQL9LB']").val()

works

Please, help

+4
source share
2 answers

Try with this

"QNTAnswer" : self.page.find("input[chkid=" + res[i] + "]").val()

If everything still does not work, try to find out the value input[chkid=" + res[i] + "]using the debugger.

0
source

Make sure your res [i] is not null or undefined. Also, you cannot find textarea as input.

Try the following:

"QNTAnswer" : res[i] != null ? self.page.find("textarea[chkid='"+res[i]+"']").val() : "your default value",
0
source

Source: https://habr.com/ru/post/1540648/


All Articles