Hi Thomas,

Back in the day, the only way to switch out of a frame was to
call WebDriver.TargetLocator.defaultContent() which indeed switches to the
top level document in the browser and it is what is used at the end of
withFrame() execution. But after you brought this to my attention I had
another look and it seems that WebDriver.TargetLocator.parentFrame() has
been introduced in WebDriver 3.x. I therefore created an issue to switch to
using this new method to better support the frame context when nested
withFrame() calls are used: https://github.com/geb/issues/issues/612.

Cheers,
Marcin

On Wed, Apr 29, 2020 at 4:33 PM Thomas Hirsch <[email protected]> wrote:

> Hello Marcin,
>
> I just came across this issue just now, while having a similar problem
> with nested frames.
> It seemed to me like the browser would always end up in the top level
> document after a withFrame call, at least adding driver.switchTo().frame()
> after every call to  withFrame (inside a nested frame (!!!)) is solving
> the issue for me right now.
> Looking at the code of DefaultFrameSupport, there is indeed a call to
> driver.switchTo().defaultContent(), in the finally block of
> executeWithFrame...
>
> I am assuming that driver.switchTo().defaultContent() would indeed switch
> to the top level document in the browser, as opposed to the next higher up
> frame, do you know if that is actually true?
>
> Here is the code of my method inside a page loaded inside a frame (inputs
> for cardNumber and CVV are inside nested frames), and it worked after
> adding the lines below the comments:
>
> void inputCreditCardDetails(
>         String cardNumber,
>         String expiryDate,
>         String holderName,
>         String cvv) {
>
>     withFrame(cardNumberIframe) {
>         cardNumberInput << cardNumber
>     }
>     // Not sure why we need this extra frame switching here...
>     driver.switchTo().frame($('.checkout-modal-iframe').firstElement())
>     expiryDateInput << expiryDate
>     holderNameInput << holderName
>     withFrame(cvvInputIframe) {
>         cvvInput << cvv
>     }
>     // Not sure why we need this extra frame switching here...
>     driver.switchTo().frame($('.checkout-modal-iframe').firstElement())
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/geb-user/665a6164-5146-47d8-8ce0-59dd3aa22891%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/665a6164-5146-47d8-8ce0-59dd3aa22891%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "Geb 
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/CA%2B52dQR9WvzJc_z0H9WY7ZktZRS7RHiuWBm2HgXSdqg-cFpP5w%40mail.gmail.com.

Reply via email to