qahive / robotframework-puppeteer

Puppeteer Web testing library for Robot Framework
Apache License 2.0
56 stars 14 forks source link

Importing PuppeteerLibrary in Robot Framework prevents graceful termination #139

Closed v8sharma closed 2 years ago

v8sharma commented 2 years ago

If you have library import Puppeteer added then the test execution does not terminate gracefully after pressing CTRL+C once when running test case via command line.

Python: 3.7.4 Robot Framework: 4.1.2 RobotFramework-PuppeteerLibrary: 3.1.0

This seems to behave similar to bug reported in https://github.com/robotframework/robotframework/issues/3798

For example:

*** Settings ***
Library           PuppeteerLibrary

*** Test Cases ***
TestSomething
    FOR    ${i}    IN RANGE    ${30}
        log    ${i}    console=True
        sleep    1s
    END

Open windows command prompt from test case location and run: "robot --outputdir C:/AutomationLogs --test TestSomething ."

Press CTRL+C once after test execution has started.

Observations: With PuppeteerLibrary import:

==============================================================================
Basic Testing
==============================================================================
Basic Testing.temp Test.
==============================================================================
TestSomething                                                         0
1
2
[ ERROR ] Execution stopped by user.
TestSomething

Without PuppeteerLibrary import:

==============================================================================
Basic Testing
==============================================================================
Basic Testing.temp Test.
==============================================================================
TestSomething                                                         Second signal will force exit.
TestSomething                                                         | FAIL |
Execution terminated by signal
------------------------------------------------------------------------------
Basic Testing.temp Test.                                              | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Basic Testing                                                         | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  C:\AutomationLogs\output.xml
Log:     C:\AutomationLogs\log.html
Report:  C:\AutomationLogs\report.html
atthaboon commented 2 years ago

Thanks a lot @v8sharma I will try the solution from the link you share.

v8sharma commented 2 years ago

@atthaboon Thanks for the quick update, however the reason I removed my previous comment regarding the ExecutionFailed error was because I still ran into this issue after adding the exception instead of sys.exit(0). The CTRL+C signal is not being caught If I add Open Browser keyword before the for loop.

v8sharma commented 2 years ago

I did more digging and found that the issue is with the signal handler in the pyppeteer library. https://github.com/pyppeteer/pyppeteer/blob/6320c084e4586960a4622d7cfefd44c2dea108a5/pyppeteer/launcher.py#L158