Why am I getting errors when trying to get the driver to click on the reCaptcha
button?
this is the site where i am trying to get it to work: https://rsps100.com/vote/760/
This is my current code so far:
WebElement iframeSwitch = driver.findElement(By.xpath("/html/body/div[1]/div/div[1]/div/div/div[2]/div/form/div/div/div/div/iframe"));
driver.switchTo().frame(iframeSwitch);
driver.findElement(By.cssSelector("div[class=recaptcha-checkbox-checkmark]")).click();
Use
WebDriverWait
to identify the element.See if this help.This worked for me. Please note that I am using Selenide. For regular selenium code look the same.
To invoke
click()
on the reCaptcha checkbox as the element is within an<iframe>
you need to:You can use the following solution:
Code Block:
Browser Snapshot:
Here is the code that should work.