driver.switchTo().frame(iframe) works fine for iframes which are not directly under body tag.
Ex: <body><div><iframe></iframe></div></body>
iframe in w3schools is not directly under body tag. https://www.w3schools.com/
Selenium webdriver fails to switch to iframes directly under body tag.
Ex: <body><iframe></iframe></body>
https://github.com/stripe/stripe-payments-demo
Selenium Jar used: selenium-server-standalone-3.8.1.jar
$ chromedriver -v
ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef)
Chrome Version 83.0.4103.116 (Official Build) (64-bit)
Please note there is no error thrown. The driver is still in default frame even after driver.switchTo().frame(iframe);
.
Same issue is over here : https://groups.google.com/g/selenium-users/c/zyg6CvRteQ8