gradle hangs with selenium in my test case while eclipse does not even with driver.quit - selenium

I have been poking around quite a bit trying to solve this. This test case
https://github.com/deanhiller/webpieces/blob/master/webserver/projecttemplates/templateProject/TEMPLATEAPPNAME-prod/src/test/java/PACKAGE/WithSeleniumTest.java
hangs in gradle but not in eclipse. Basically, clone the project and "./gradlew test" hangs.
I am going to research debug mode for unit tests but not sure that gets me very far from the posts I have been reading like
https://discuss.gradle.org/t/help-my-gradle-script-hangs-during-build-at-end-of-tests/7505/15
So I ran the specific test in debug mode
./gradlew -Dtest.single=WithSeleniumTest :webserver:projecttemplates:templateProject:TEMPLATEAPPNAME-prod:test --debujvm
And it definitely got all the way to class teardown calling driver.quit() but then just hung for some reason :(.

ouch....I was calling driver.quit() but actually had to call
driver.close()
driver.quit()
and now it doesn't hang!!!!
ugh...why two method calls.

Related

Is it possible to run all the tests using mocha even if there are some failures?

I am working on a node.js application and would like to know if there is a way I can run all the unit tests from all the sub modules even if there are some test failures to know how many tests are failing in total to start putting the fixes for them. We use mocha for our tests on the back-end and jest for the ui.
Thanks.
The default behavior for mocha is to run all the tests. If it is exiting after the first test failure, that would suggest that you are using the "bail" option typically enabled on the command line with either --bail or -b.
Relevant docs: https://mochajs.org/#-bail-b
It can also be caused by passing the option { bail: true } to mocha.setup(). Look in your test runner and in your package.json.
Lastly, the least likely of these possibilities is that it could also be caused by using this.bail() somewhere in the Mocha test runner.

jest, logging success or failure between each test while the tests are running

seems like something quite basic but it dosen't seem to be available in jest automatically.
when i run my jest tests, during the test run i get the logging info from the code itself while the tests are run.
and only after the tests are finished i receive a summary of the spec results(which tests passed and which didn't).
what i'm trying to achieve is to have extra lines in my console, that fill while the tests are running, that tell which test we have just finished, and what was the result.. this will make log debugging so much simpler..
thanks!

Display selenese-runner results in Jenkins

As I am implementing an automated way to GUI test our webapplication with selenium I ran into some issues.
I am using selenese-runner to execute our Selenium test suites, created with Selenium IDE as a post build action in Jenkins.
This works perfeclty fine, as the build fails when something is wrong, and the build succeeds if all tests are passed. And the results are stored on a per build basis as HTML files, generated be selenese-runner.
My problem is however, that I seem to be unable to find a way, how to display these results in the respective jenkins build.
Does anyone have an idea how to solve this issue. Or maybe I am on the wrong path at all?
Your help is highly appreciated!
I believe the JUnit plugin should do what you want, but it doesn't work for me.
My config uses this shell script to run the tests (you can see the names of all my test suites):
/usr/bin/Xvfb &
export DISPLAY=localhost:0.0
cd ${WORKSPACE}
java -jar ./test/selenium/bin/selenese-runner.jar --baseurl http://${testenvironment} --screenshot-on-fail ./seleniumResults/ --html-result ./seleniumResults/ ./test/selenium/Search_TestSuite.html ./test/selenium/Admin_RegisteredUser_Suite.html ./test/selenium/Admin_InternalUser_Suite.html ./test/selenium/PortfolioAgency_Suite.html ./test/selenium/FOAdmin_Suite.html ./test/selenium/PublicWebsite_Suite.html ./test/selenium/SystemAdmin_Content_Suite.html ./test/selenium/SystemAdmin_MetaData_Suite.html
killall Xvfb
And I can see the result of the most recent test (you can see the name of my jenkins task folder)
http://<JENKINS.MY.COMPANY>/job/seleniumRegressionTest/ws/seleniumResults/index.html
Earlier tests are all saved on the Jenkins server, so I can view them if I need to.

run nightwatchjs in watch mode

I'm searching for the equivalent of mocha:
mocha test.spec.js -w
opening nigtwatch manually on every change burns a lot of time during test writing.
any ideas of this?
I've checked nightwatch docs and google, nothing came up
From what I've seen, there isn't a --watch mode or command for nightwatch. This is only an answer in that what I've seen confirms that this doesn't seem to exist.
Here are the sources that led me to this conclusion, including possible leads for other solutions:
I've found an issue in the nightwatch repo asking about that in 2016: https://github.com/nightwatchjs/nightwatch/issues/1061. The answer then was
'No, but you can use something like the grunt-contrib-watch module.'
I found a stackoverflow question in 2018 that talks about how nightwatch, and other things using selenium, always return exit code 1: Nightwatch.js always returns exit code 1. That leads me to believe that nightwatch always exits its tests. The question was asking about integrate Nightwatch.js tests in a Jenkins Job. A comment offers a possible solution for that, so maybe it's possible to make a wrapper for nightwatch this way:
This happens with other selenium based libraries as well. I think I ran into this issue with protractor in the past. The way we tackled it was by parsing the output instead of using the exit code and looked for any failures. If none were found then we returned 0 explicitly... you can check for failed tests using browser.currentTest.results.failed and then figure out a way to pass or fail your build based on that.

Running WEbDriver tests

So i have been writing Selenium tests for a while now and i have been running the only from the IDE untill now.
i would like to be able to write a script that runs all my tests sequentialy.
I am using the testng framework with eclipse and selenium-2.0b3 jar.
What i'd like is eventually to have a file like "runSeleniumTests.bat" witch just runs them and gives me some sort of report when in finishes.
if anyone has an idea, it will be very greatly appreciated, thanks :)
This has 4 options for how to run testng tests the xml file should include all your tests
http://testng.org/doc/documentation-main.html#running-testng
You could also try to use maven and as long as your tests are annotated correctly and in /src/test/java they will all be run for you with mvn integration-test (as long as you have the proper dependencies defined and I believe maven-surefire-plugin). This might be more difficult to setup initially but usually pays off.