【发布时间】:2019-07-24 00:26:22
【问题描述】:
当我尝试在 selenium 中获取 reCaptcha v2 图像时,我得到 no such this element,因为该元素不在主页中
那么如何在 selenium C# 中获取图片!
_driver.Navigate().GoToUrl("https://www.google.com/recaptcha/api2/demo");
_driver.SwitchTo().Frame(0);
_driver.FindElement(By.Id("recaptcha-anchor")).Click();
Thread.Sleep(5000);
_driver.SwitchTo().Frame(0);
//To get all images in page
IList<IWebElement> images = _driver.FindElements(By.TagName("img"));
MessageBox.Show(images.Count.ToString());
string reCaptchaXpath = "";
foreach (var img in images)
{
if (img.GetAttribute("src").Contains("https://www.google.com/recaptcha/api2/"))
{
reCaptchaXpath = GenerateXpath(img, "");
}
}
【问题讨论】:
-
请澄清您的具体问题或添加其他详细信息以准确突出您的需要。正如目前所写的那样,很难准确地说出你在问什么。请参阅How to Ask 页面以获得澄清此问题的帮助。
标签: c# selenium recaptcha captcha