Unable to switch to Google Sign in window

i am trying to switch to a new window that has the google sign in page, but my script fails to find the window with that title.

I am using the command :

WebUI.switchToWindowTitle("Sign in - Google Accounts")

But the test fails with

Caused by: com.kms.katalon.core.exception.StepFailedException: Cannot find window with title: 'Sign in - Google Accounts'

Also I tried with

WebUI.switchToWindowIndex(1)

But the test fails with

Caused by: com.kms.katalon.core.exception.StepFailedException: Cannot find window with index: '1'

Does someone knows how to switch to the google sign in window?

I was able to successfully switch to PayPal sign in popup window.

I’ve never used Google sign-in with an AUT but to me, that doesn’t look like a window, more like a popup element done in pure HTML

Do you know if there’s a way to switch to this kind of popup element?

Perhaps I’m more awake today… ignore my first post, it seems I missed the fact you posted the code in your screenshot – it does seem to be a popup window.

The only guy I’d ask to take a look is @Brandon_Hein (our resident Chrome guy).

Sit tight, he should be around soon.

Did you try another browser? Firefox? (that will avoid chromium/blink).

Is it possible that the popup contents are actually contained in an <iframe> element? If you can share the top of the HTML that would be helpful.

Also, you should be able to see all windows that the driver knows about by running this:

WebDriver driver = DriverFactory.getWebDriver();
Set<String> handles = driver.getWindowHandles();
for(String handle : handles) {
    System.out.println(driver.switchTo().window(handle).getTitle())
}

As a final option, you may be able to just navigate to the google sign in page prior to running your test case and sign in there ahead of time.

@Brandon_Hein

I have confirmed that the actual elements on the popup do not exist within an iframe but a div container.

Try running the code above to see which windows are available to the driver.

I don’t see evidence that the iframe is contained in any div element – devtools shows the preceding divs as closed with “…” as their content.

Quite why Chrome devtools is showing them indented I’m not sure.

Doesn’t help with the issue though – but there’s something weird about that devtools layout. Brandon?

I’d be very interest to see the highlighted div expanded.

Eh, looks fine to me, I just wanted to make sure that the modal wasn’t embedded in an iframe, which it isn’t. There are some additional iframes there, but looks like the target content is within that div. It’s possible there are iframes further down in the tree, as you said.

Now we just need to find out why we can’t switch to the window by title as in the OP.

@Russ_Thomas, @Brandon_Hein

Add any of the product to cart on Dell website and on checkout you will find the google pay option. You can check the complete HTML there.

Open it in Incognito if you have your card details saved otherwise.

1 Like

It’s a page for me, not a popup (Firefox and Chrome).

@Russ_Thomas

Are you trying to click on this button on the cart page?

I think you are clicking check out, and that takes you to the screen you attached earlier. Click on the google pay button on the cart itself.

Ok I’m recreating this on my machine. It doesn’t appear that webdriver can access this new “window”. It can only see the original window of the dell website.

However, I did find this <iframe> in the body of the dell page:

Try locating and switching to this frame, then doing your pathing to sign into google from there.

I see that iframe on my AUT as well but the test fails all the same with the error:

Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/AccountManagement/test' located by 'iframe[src*="https://pay.google.com"]' not found

Although I am able to locate the iframe on my AUT with 'iframe[src*="https://pay.google.com"]' but the test is not able to locate the element.

Try this xpath:

//iframe[contains(@src, 'pay.google.com')]

Yep, the test did not fail on the switchToFrame call but it was unable to locate the email field on the pop up.

Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: 'Object Repository/AccountManagement/EmailAddressInputBox' located by 'input[type="email"]' not found```

Can you share the locator that is being used in your test object for the email field?

Should I select the parent iframe?

Hmmm I’m not well-versed in CSS locators. It’s possible that your locator is correct, assuming that switching to the iframe puts you in the right context. @Russ_Thomas is this locator valid?

If the iframe doesn’t work, I’d suggest signing into google in another way to get around this.