Hello
I have the problem that I want to be able to manipulate the reCaptcha v2 using Selenium but I can't click on an element inside.
My code:
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@name, 'a-') and starts-with(@src, 'https://www.google.com/recaptcha')]")));
new WebDriverWait(driver, 30).until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.rc-anchor-content"))).click();
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@name, 'c-') and starts-with(@src, 'https://www.google.com/recaptcha')]")));
new WebDriverWait(driver, 30).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"recaptcha-reload-button\"]"))).click();
My code manages to find the Captcha and click and in theory it should be able to find the other iframe where the options and images are displayed. But you don't get it and so you can't click the reload button .
The error present in the console:
*** Element info: {Using=xpath, value=//iframe[starts-with(@name, 'c-') and starts-with(@src, ' https://www.google.com/recaptcha')]} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang .reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec .java:122) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at org.openqa. selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323) at org.openqa .selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:428) at org.openqa.selenium.By$ByXPath.findElement(By.java:353) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java :315) at org.openqa.selenium.support.ui.ExpectedConditions$17.apply(ExpectedConditions.java:501) at org.openqa.selenium.support.ui.ExpectedConditions$17.apply(ExpectedConditions.java:497) at org. openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249) ... 36 more console.error: "Store does not have a valid reducer.Make sure the argument passed to combineReducers is an object whose values are reducers."
The problem is that you have to return to the default content between an action on an iframe and the next:
The second frame is not visible from the first, but from the default content.
To explain the steps a little better:
DC -> iFrame A -> DC -> iFrame C