0

On the website I am trying to fill in some fields on, there is a checkbox that I need to click to add the check mark in it:

<div class="rc-anchor-content"><div class="rc-inline-block"><div class="rc-anchor-center-container"><div class="rc-anchor-center-item rc-anchor-checkbox-holder"><span class="recaptcha-checkbox goog-inline-block recaptcha-checkbox-unchecked rc-anchor-checkbox recaptcha-checkbox-expired" role="checkbox" aria-checked="false" id="recaptcha-anchor" dir="ltr" aria-labelledby="recaptcha-anchor-label" aria-disabled="false" tabindex="0"><div class="recaptcha-checkbox-border" role="presentation" style=""></div><div class="recaptcha-checkbox-borderAnimation" role="presentation" style=""></div><div class="recaptcha-checkbox-spinner" role="presentation" style="transform: rotate(180deg);"></div><div class="recaptcha-checkbox-spinnerAnimation" role="presentation" style=""></div><div class="recaptcha-checkbox-checkmark" role="presentation"></div></span></div></div></div><div class="rc-inline-block"><div class="rc-anchor-center-container"><label class="rc-anchor-center-item rc-anchor-checkbox-label" aria-hidden="true" role="presentation" id="recaptcha-anchor-label"><span aria-live="polite" aria-labelledby="recaptcha-accessible-status"></span>I'm not a robot</label></div></div></div>

Using Selenium in VBA, I tried the following

.FindElementByCss("div.recaptcha-checkbox-border").Click

And also I tried

.FindElementByCss("span.recaptcha-checkbox").Click

But I got an error at this line.

Here's the link of the website to see the whole HTML https://www.moj.gov.kw/AR/E-Gov/Pages/eServices01.aspx

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
YasserKhalil
  • 9,138
  • 7
  • 36
  • 95
  • 1
    If you could use selenium to bypass *I am not a robot* it wouldn't be very useful. – Guy Jul 17 '19 at 11:14
  • This is the second post I've seen this week where someone is trying to do exactly what the site doesn't want them to do. It might be doable but what you are attempting to do may very well be illegal. I would strongly advice against it – Zac Jul 17 '19 at 11:15
  • @Zac Thanks a lot. I have edited the main post and removes any illegal requests. – YasserKhalil Jul 17 '19 at 12:09

1 Answers1

1

To click() on the element, as the desired element is within an <iframe> so you have to:

  • Induce a waiter and switch to the desired frame.
  • Induce a waiter for the desired element to be clickable.
  • You can use the following solution:

    .SwitchToFrame.FindElementByXPath("//iframe[contains(@src, 'recaptcha') and not(@title='recaptcha challenge')]", timeout:=10000)
    .FindElementByCss("div.recaptcha-checkbox-checkmark").Click
    

You can find similar discussions in:

Here you can find a relevant discussion on Ways to deal with #document under iframe

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352