Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Driver closes after 'call read()', but not after 'karate.call()' #2351

Open
LuuKroHY opened this issue Jun 30, 2023 · 4 comments
Open

Driver closes after 'call read()', but not after 'karate.call()' #2351

LuuKroHY opened this issue Jun 30, 2023 · 4 comments

Comments

@LuuKroHY
Copy link

Using the following minimal example:

Feature: Feature showing the difference between call methods

@ignore @tocall
Scenario: Called scenario
    * driver 'https://www.google.com/'

Scenario: Using call read()
    * call read('@tocall')

Scenario: Using karate.call()
    * karate.call('@tocall')

The browser window closes automatically after the first Scenario (pass or fail), but stays open after the second, staying open even after all tests are completed. Reversing the order of the Scenario's causes the browser window to stay open after the now first Scenario, and a second browser windows opens (and closes) for the second.

Using Windows 11, Karate 1.4.0, Chrome 114.0.5735.199.

The actual issue I'm dealing with is the following:
I need to call a feature from a JavaScript function. I can use karate.call() in JavaScript, but (AFAIK, I could be wrong) can't use 'call read()' in JavaScript. I added a 'quit()' to the end of the called feature, but if it fails, the browser window stays open, even after the tests are completed.
Is there a solution or workaround available for this issue?

@ptrthomas
Copy link
Member

@LuuKro can you do this quick test

Scenario: Using karate.call()
    * karate.call(true, '@tocall')

So the true is a flag to say that the call should be in "shared" scope, explained here: https://github.com/karatelabs/karate#call-vs-read

let me know if that works and the docs may need to be updated and maybe we need to fix this issue you reported. so yes, the whole browser / driver mechanism in karate is designed to work only in "shared scope".

@ptrthomas ptrthomas self-assigned this Jun 30, 2023
@LuuKroHY
Copy link
Author

I tried it, and it mostly solved the issue! However, if the called scenario fails, the 'call read()'-Scenario fails instantly, while the 'karate.call()'-Scenario stays open for 30 seconds. This can be easily replicated by modifying the first Scenario above as such:

@ignore @tocall Scenario: Called scenario * driver 'https://www.google.com/' * match 1 == 2

Looking at the logs, it seems like it has something to do with Chrome's screenshot-functionality failing in the second Scenario:

14:54:50.228 [main] ERROR c.i.k.driver.chrome_1688129659545 - << timed out after milliseconds: 30000 - [id: 8, sessionId: 064FCADF0791AEB1E204E7CE9EB23986, method: Page.captureScreenshot] 14:54:50.229 [main] ERROR c.i.k.driver.chrome_1688129659545 - screenshot failed: failed to get reply for: [id: 8, sessionId: 064FCADF0791AEB1E204E7CE9EB23986, method: Page.captureScreenshot]

I'm afraid my technical knowledge about this is too limited to do an actual Root Cause Analysis, but I hope this helps.

Concerning changing the docs, it might be an idea to expand the 'call vs read()'-header to 'call vs read() vs karate.call()'?

In any case, thanks for the help! Having the tests take a little longer if one of them fails is a lot less cumbersome than ending a testset with 20 Chrome windows open 😄

@ptrthomas
Copy link
Member

@LuuKro thanks for the details. are you on Karate 1.4.0 because I thought we tried to make that screenshot part a little better. but we will look into this particular issue for sure

@ptrthomas
Copy link
Member

@LuuKro nevermind, just noticed you mentioned you are on 1.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants