How can I stop or pause playframework Selenium tests on error? - testing

I'd like to stop or pause Selenium test when running with playframework, because I can't see what is wrong!
Is there a way to preserve the window with my application on the step where it failed? It automatically closes that window!

You could try a few things after you pin point exactly which step causes the error:
Put a wait command in your selenium test to pause the test so you can see what is going on in the UI
You could start the debugger and put a break point on some code that gets executed on the server after the failure happens (assuming the test continues running after the failure)
You could use the selenium test runner panel to slow down the speed of the test so you can see the error (i.e. I'm referring to the speed slider that you see when you run the tests in the browser via the url http://localhost:9000/#tests)

Related

Timed out retrying. Expected to find element but never found it. Failed on CI

I am having an issue in Github Actions.
I am using Cypress to test the frontend of my app, and everything is working perfectly in the Cypress app.
But when I am pushing everything on master in GitHub and run the test via Github Actions, every now and then, the same flaky test is failing with he following error.
Timed out retrying after 5000ms: Expected to find element "xxx" but never found it.
This line is the problematic one:
cy.purposeElement("delete_user_dialog").should('be.visible')
The element we are talking about takes 0.2s to appear with a fade-in animation.
My guess is that the page was slow to respond, while Cypress was fast to act.
How can I avoid solve a flaky test like that?
I could use a cy.wait but it is not recommended and I do not want to increase the time of the test.
Plus, the result is as flaky.
It may be as simple as increasing the timeout, especially if the test works perfectly when running on the local machine.
cy.purposeElement("delete_user_dialog", {timeout:20_000}).should('be.visible')
To be 100% sure, do a burn test which is described here: Burning Tests with cypress-grep

Codeception disregard specific error types and relaunch test

Is there a way to tell the system to restart the test in case a specific rare system error comes up?
Basically sometimes we get strange errors related to elements being "obscured" or "stale", but which do not mean the site is not working etc. It has to do with the site's latency I believe like CSS not loading quickly enough etc.
For example is there a directive to tell the system that if an error like
[Facebook\WebDriver\Exception\ElementClickInterceptedException] Element
\<li id="nav_step0" class="nav-steps selected"> is not clickable at point (330,237)
because another element \<div id="ajaxloading_mask" class="mask"> obscures it
To simply relaunch the test again?
No, there is no way to relaunch failed test on specific error.
You can rerun all failed tests:
codecep run || codecept run -g failed
This command executes all tests, if any tests failed, it reruns only failed tests.

Is it possible to not shutdown webdriver between two protractor spec execution?

I would like to run separate protractor specs without closing the browser in between.
Something like:
Open the browser and go to the URL
then, run "protractor conf.js --specs=spec1.js"
then, do some actions on the SUT, typically do some actions on our simulator (so, non protractor actions)
then, run "protractor conf.js --specs=spec2.js"
and finally close the browser and shutdown the webdriver.
The goal is to keep the context between the protractor specs execution.
Is it possible?
Correction and Additional information:
My need is to keep the browser opened between two separate test suites (in separate files) and not between two tests.
I'm using IE11 alongside selenium standalone server.
Thank you.
Protractor by default doesnt close the browser between each session unless you specifically ask it do so. The below option in config file controls that.
/** * If true, protractor will restart the browser between each
test. Default * value is false. * * CAUTION: This will cause
your tests to slow down drastically. */
restartBrowserBetweenTests?: boolean;
Looks like your requirement is
Execute Spec 1
Execute some task outside browser(non-protractor work)
Then Execute Spec 2
Normally how I implement this is - lets say I have a task to validate & confirm email from my outlook , which is a non-protractor task before I run next test case, I just throw an alert at the end of my 1st test case asking the tester to manually verify the email and then accept the alert on the browser and then I will proceed with the second test case

Is there console.log output support to terminal/command-line with intern-runner?

I have a dependency with Intern where we have to spin up a Selenium server and use PhantomJS for our tests. We use Jenkins and may need some more inspection/debug output to console but the console.log's get suppressed from the test files to terminal/command-line
Is console.log to terminal/command-line supported yet?
How console.log works with intern-runner depends on where your test code is running. Unit tests (specified with suites) run in the browser, so that's where console.log output ends up. There isn't currently a way to get console output out of a browser for unit tests.
Functional tests (specified with functionalSuites) control a browser, but actually run in Node.js, so output from console.log statements in functional tests generally goes to intern's stdout. The exceptions are log statements in execute and executeAsync blocks; since those blocks run in the browser, that's where the log output ends up. You can retrieve browser logs in functional tests using getLogsFor('browser'), but WebDriver log support is inconsistent between browsers.

Remote Debugging with Squish IDE

I want to do remote debugging of Squish application.
I am following document at:
http://kb.froglogic.com/display/KB/Configuring+a+remote+squishserver
for the same.
Step 1 and Step 2 went well, even I able to see the logs in terminal from remote application.
But, the debug point is not hitting in Squish IDE. Even the debug view shows nothing though I have done the exact steps given at Step 3, even restart of Squish IDE didn't help.
Whether or not Squish stops at a breakpoint (I suppose that's what you meant when you wrote "debug point") is independant of where the squishserver process is running. You can verify that the remote server is used simply by launching a test: you should see some output in the console where squishserver is started about incoming network connections.
When running squish remotely you could add the flag: "--reportgen xml3.3,xml3report" This will create a report with all the information about your run. You can then import this report into squshIDE and use "vpdiff" tool to analyze your failure.
There is a command line tool called "vpdiff" which comes in SQUISHDIR/bin.
There is an article about it here:
https://www.froglogic.com/blog/analysing-test-reports-from-automated-executions-using-the-squish-ide/