CSS 使用 Selenium 和 VBA Excel 的 reCAPTCHA 复选框选择器
CSS selector for reCAPTCHA checkbok using Selenium and VBA Excel
在我尝试填写某些字段的网站上,有一个复选框,我需要单击以在其中添加复选标记:
<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,我尝试了以下方法
.FindElementByCss("div.recaptcha-checkbox-border").Click
我也试过了
.FindElementByCss("span.recaptcha-checkbox").Click
但是我在这一行出错了。
这里是网址link,看全HTML
https://www.moj.gov.kw/AR/E-Gov/Pages/eServices01.aspx
到 click()
元素,因为所需元素在 <iframe>
内,所以您必须:
- 诱导服务员切换到想要的画面
- 为所需的 元素设置可点击的服务员。
您可以使用以下解决方案:
.SwitchToFrame.FindElementByXPath("//iframe[contains(@src, 'recaptcha') and not(@title='recaptcha challenge')]", timeout:=10000)
.FindElementByCss("div.recaptcha-checkbox-checkmark").Click
您可以在以下位置找到类似的讨论:
Here you can find a relevant discussion on
在我尝试填写某些字段的网站上,有一个复选框,我需要单击以在其中添加复选标记:
<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,我尝试了以下方法
.FindElementByCss("div.recaptcha-checkbox-border").Click
我也试过了
.FindElementByCss("span.recaptcha-checkbox").Click
但是我在这一行出错了。
这里是网址link,看全HTML https://www.moj.gov.kw/AR/E-Gov/Pages/eServices01.aspx
到 click()
元素,因为所需元素在 <iframe>
内,所以您必须:
- 诱导服务员切换到想要的画面
- 为所需的 元素设置可点击的服务员。
您可以使用以下解决方案:
.SwitchToFrame.FindElementByXPath("//iframe[contains(@src, 'recaptcha') and not(@title='recaptcha challenge')]", timeout:=10000) .FindElementByCss("div.recaptcha-checkbox-checkmark").Click
您可以在以下位置找到类似的讨论:
Here you can find a relevant discussion on