1

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
PBMax
  • 242
  • 3
  • 15

2 Answers2

1

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.

PBMax
  • 242
  • 3
  • 15
0

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

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 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 resolveable. I updated the question with the code I created to do so. I may just need to expose unreachable URL as a property if I'm going to update the framework. Maybe have a property called "driver.unreachableUrl" ? – PBMax Jul 23 '21 at 19:51
  • @PBMax that's really hard to understand. another option is please follow this process or replicate: https://github.com/intuit/karate/tree/develop/examples/ui-test – Peter Thomas Jul 23 '21 at 19:53
  • Sorry about that. These comments don't format well and I actually updated my original question with the code that I am actually trying to get to work again. The issue is if you go to a url that is not resolvable you will get a chrome-error://chromewebdata value returned if you try to get the url via driver.url. My solution was to get the page frame to parse out the unreachable url. I'll look into submitting a project to make it easy to reproduce. The original scenario for get frame tree will reproduce with http://localhost as the url. – PBMax Jul 24 '21 at 01:06
  • I think I figured it out. It seems that this update removed the Result from the conversion to a Map. I added the code locally to test it fixed my problem. Why was this change needed/done? How can we get this fixed? putting these lines back fixes the issue: if (result != null) { map.put("result", result); } https://github.com/intuit/karate/commit/8f7d6e03604374a85fe7b8d52c81a23c2a45cace#diff-446634215c4ea0b238ab34920e7693aef931e0af453293a7cefd11119093a666L217 – PBMax Jul 26 '21 at 20:48
  • 1
    I submitted this as an issue here: https://github.com/intuit/karate/issues/1690 – PBMax Jul 27 '21 at 01:15