使用Selenium和VBA Excel的reCAPTCHA checkbok的CSS选择器 [英] CSS selector for reCAPTCHA checkbok using Selenium and VBA Excel
本文介绍了使用Selenium和VBA Excel的reCAPTCHA checkbok的CSS选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我要填写其上某些字段的网站上,有一个复选框需要单击以在其中添加复选标记:
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
但是这行我出错了.
这是网站的链接,可以查看整个HTML https://www.moj.gov.kw/AR/E-Gov/Pages/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
推荐答案
要对元素进行 click()
,因为所需元素在< iframe>
内所以你必须:
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:
这篇关于使用Selenium和VBA Excel的reCAPTCHA checkbok的CSS选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文