使用 Selenium 和 VBA Excel 的 reCAPTCHA 复选框的 CSS 选择器 [英] CSS selector for reCAPTCHA checkbok using Selenium and VBA Excel
问题描述
在我尝试填写某些字段的网站上,有一个复选框,我需要单击以在其中添加复选标记:
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>
在VBA中使用Selenium,我尝试了以下
Using Selenium in VBA, I tried the following
.FindElementByCss("div.recaptcha-checkbox-border").Click
我也试过了
.FindElementByCss("span.recaptcha-checkbox").Click
但是我在这一行遇到了错误.
But I got an error at this line.
这是网站的链接,可以查看整个 HTMLhttps://www.moj.gov.kw/AR/电子政务/页面/eServices01.aspx
Here's the link of the website to see the whole HTML https://www.moj.gov.kw/AR/E-Gov/Pages/eServices01.aspx
推荐答案
To click()
在元素上,因为所需的元素在 所以你必须:
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:
在这里你可以找到关于处理#document下的方式的相关讨论框架
这篇关于使用 Selenium 和 VBA Excel 的 reCAPTCHA 复选框的 CSS 选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!