Puppetter - [Element Exists] not finding hidden elements


I’m looking for a hidden element (hidden recaptcha) to set a keycheck for its existance

[Wait for Element] block has the “Hidden” checkbox and it will find it but [Exists] block can’t

Is there an alternative ?

Use an execute js block and do it in javascript directly

thx, Not good on JS but will search for it

I’ll appreciate a hand if somebody knows the snippet

I’m using CSS selector to track my element and as for a reminder it’s hidden and the result must be boolean

wrote a little code with some help but something seems to be wrong

Can “document.contains” track hidden objects ?

var element=document.querySelector("#rc-imageselect")
var recaptchaExists=document.contains(element);
END SCRIPT -> VARS "element,recaptchaExists"

“hidden” objects should still be present in the DOM, they are just hidden from the view and not rendered to screen, no?

Unfortunately it doesn’t appear in DOM at all and it’s hidden from sight as you say

Currently the only thing that can access it is [Wait for Element] with hidden checked

I also tried the above code and seems like I can’t talk with the browser, how can I use document from current selenium ?


[Executing block Script] JavaScriptException: document is not defined

You need the “Execute JS” block not the “Script” block

You have to return the value, otherwise it just creates a variable without returning anything to OB2. So instead of "var recaptchaExists = " put “return”
Since you have 2 lines you need to decide which one you want to get, in this case the second one so put return document.contains(element); and leave the first line as is

1 Like

Useful tip, thanks

however as I type the following in ExecuteJS block

var element=document.querySelector("#rc-imageselect"); return document.contains(element);

I get this error:

[Executing block Execute JS] EvaluationFailedException: Evaluation failed: SyntaxError: Illegal return statement

Try without return, I had the same error yesterday

also tried that, same result

samples that I tried:

1. return document.contains(document.querySelector("#rc-imageselect"));

2. document.contains(document.querySelector("#rc-imageselect"));

3. var element=document.querySelector("#rc-imageselect"); return document.contains(element);

4. var element=document.querySelector("#rc-imageselect"); document.contains(element);

please use waituntillexist or Delay LOCK, then try the code, it’s work for me or check your browser, this is not working in edge.