PBMax
PBMax

Reputation: 262

Chrome Driver with Karate 1.0.1 does not get frame tree

I previously posted the question below which was resolved by upgrading Karate to 0.9.6.

When using the chrome driver with Karate UI the driver.send command is not working

Now when I upgrade to Karate 1.0.1 the code that previously worked in 0.9.6 no longer works. I checked the docs at the link below and it hasn't changed.

https://intuit.github.io/karate/examples/ui-test/#devtools-protocol-tips

When running the code below I don't get the frameTree back that I expect even though the driver output shows the frameTree I want:

  Scenario: Get Frame Tree
    * driver 'https://google.com'
    * def frame = driver.send({ method: 'Page.getFrameTree' })
    * print frame

Here is the actual output:

17:01:26.738 [main] DEBUG c.intuit.karate.driver.DriverOptions - >> {"id":7,"method":"Page.getFrameTree"}

17:01:26.749 [nioEventLoopGroup-2-1] DEBUG c.intuit.karate.driver.DriverOptions - << {"id":7,"result":{"frameTree":{"frame":{"id":"EF7B9A896E378D2847F3A5FD6647353E","loaderId":"74EA753CFFDB150AE371D4CC442E0B8C","url":"https://www.google.com/","domainAndRegistry":"google.com","securityOrigin":"https://www.google.com","mimeType":"text/html","adFrameType":"none","secureContextType":"Secure","crossOriginIsolatedContextType":"NotIsolated","gatedAPIFeatures":["SharedArrayBuffersTransferAllowed"]}}}}

17:01:26.750 [main] INFO com.intuit.karate - [print] { "id": 7, "method": null }

Is this a bug with 1.0.x? I tried 1.0.1RC5 and I saw the same behavior.

Update to comment below:

I'll take a look but on first pass I don't even know what I'm looking at :) This is what I did which may have worked but was unsupported. I need to get the URL from a page that isn't resolvable.

Scenario: GetUnreachableURL
    * string frameTree = driver.send(karate.toMap({ method: 'Page.getFrameTree' }))
    * print frameTree
    # headless chrome doesn't return chrome-error on unreachableUrls
    * def unreachableUrl = driver.url == 'chrome-error://chromewebdata/' ?  karate.extract(frameTree, 'unreachableUrl=(.+?)(?=,|})', 1) : driver.url

Upvotes: 1

Views: 381

Answers (2)

PBMax
PBMax

Reputation: 262

Just wanted to update this issue that this indeed was a bug and has been fixed in 1.1.0.

https://github.com/intuit/karate/issues/1690

Thanks Peter for your support.

Upvotes: 1

Peter Thomas
Peter Thomas

Reputation: 58088

This may need you to contribute code and help, it sounds you are doing something we don't support.

The Chrome communication was re-factored in this commit: https://github.com/intuit/karate/commit/9600031f17d7a81509368d6da36c24de3e945e36

And just to make iframes work, there is a global variable set which is applied to all messages sent to Chrome, and perhaps the send() command is not considered. May I request you to contribute ? We have an easy to follow developer guide: https://github.com/intuit/karate/wiki/Developer-Guide

Upvotes: 0

Related Questions