Run TestCafe in Firefox browser using docker container via Jenkins - firefox

I want to run the TestCafe in firefox browser(not headless) through Jenkins.
I'm using docker container which has chromium and firefox installed.
When I try to run it firefox it's throwing an error as
ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.
My Jenkins file looks like
steps
{
container('testcafe') {
sh 'npm install'
sh "npm run live-docker"
}
}
where live-docker is mentioned in package.json as "live-docker":"testcafe 'firefox --no-sandbox' e2e/user.spec.js -r xunit:TEST-new_user.xml”
I even tried using "live-docker":"testcafe firefox e2e/user.spec.js -r xunit:TEST-new_user.xml” but getting the same error.

Related

Running cypress tests in docker image cypress/base:17.3.0 gives error ''CertVerifyProcBuiltin for ws14.hotjar.com failed'

I am running my tests with this docker image cypress/base:17.3.0. I got plenty of this kind of error even if the tests are passing... Any idea in order to fix them?
[33:0614/080128.399356:ERROR:cert_verify_proc_builtin.cc(681)] CertVerifyProcBuiltin for ws14.hotjar.com failed:
----- Certificate i=0 (OU=Cypress Proxy Server Certificate,O=Cypress Proxy CA,L=Internet,ST=Internet,C=Internet,CN=ws14.hotjar.com) -----
ERROR: No matching issuer found
Seems to be an electron headless browser issue.
Try setting your headless browser to chrome.
cypress run --headless --browser chrome

Docker Command Issue Running Outside of Bash

I have a Docker container that handles an application. I am attempting to write tests for my system using npx and nightwatchJS.
I use CI and to run the tests for my entire suite I docker-compose build then run commands from outside of the container like so:
Example of backend python test being called (this works and is run as expected):
docker-compose run --rm web sh -c "pytest apps/login/tests -s"
Now I am trying to run an npx command to do some front-end testing but I am getting errors with something I cannot seem to diagnose:
Error while running .navigateTo() protocol action: An unknown server-side error occurred while processing the command. – unknown error: net::ERR_CONNECTION_REFUSED
Here is that command:
docker-compose run --rm web sh -c "npx nightwatch apps/login/tests/nightwatch/login_test.js"
The odd part of this is that if I go into bash:
docker-compose exec web bash
And then run:
npx nightwatch apps/login/tests/nightwatch/login_test.js
I don't get that error as I'm in bash.
This leads me to believe that I have an error in something with the command. Can somebody please help with this?
Think as containers as a separate computers.
When you run on your computer pytest apps/login/tests -s and then I run on my computer npx nightwatch apps/login/tests/nightwatch/login_test.js surely my computer will not connect to yours. I will get "connection refused" kind of error.
With docker run you run a separate new "computer" that runs that command - it has it's own pid space, it's own network address, etc. Than inside "that computer" you can execute another command with docker exec. To have you command to connect with localhost, you have to run them on the same "computer".
So when you run docker run with the client, it does not connect to a separate docker run. Either specify correct ip address or run both commands inside the same container.
I suggest to research how docker works. The above is a very crude oversimplification.

Start Jenkins local server on Mac

I am trying to integrate CI/CD using Jenkins. I have properly set Jenkins up on my mac by installing Java JDK and all. The localhost url was also accessible. I was able to manage plugins using http://localhost:8081 url.
But I accidentally closed the terminal window and the Jenkins was stopped. The url stopped working. It now shows error
This site can’t be reached
localhost refused to connect.
I tried to run the Jenkins from terminal using this command
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
also this command:
sudo launchctl start /Library/LaunchDaemons/org.jenkins-ci.plist
The terminal asks for password, but the url still does not work. I even tried unloading the Jenkins using this command:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Then again loading and starting command. But its not working.
Any help would be appreciated. Thanks
This is how I solved the above problem
Go to Jenkins directory
/Users/me/Downloads/Jenkins
Then run Jenkins on any port (default 8080 or any other)
java -jar jenkins.war --httpPort=8081
And the localhost is working now.
This was a stupid situation.

Running nightwatch tests on a create-react-app on travis

I have an issue Running nightwatch tests on a create-react-app server (npm start) on travis. I'm starting the creat-react-app with
.travis.yml:
before_script:
- npm --prefix ./client start ./client &
script: npm run test-ci
however when nightwatch runs I am always getting
Starting the development server...
Starting selenium server... Warning: The 'no-use-before-declare' rule requires type information.
ts-loader: Using typescript#2.5.3 and /home/travis/build/client/tsconfig.json
started - PID: 4017
You can now view app in the browser.
Local: http://localhost:3000/
On Your Network: http://172.17.0.3:3000/
Note that the development build is not optimized.
To create a production build, use npm run build.
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ Error: socket hang up
However the starting & running the nightwatch tests locally works perfect.
The issue was with Chrome, not a problem with react or Nightwatch.
https://github.com/travis-ci/travis-ci/issues/8836

Selenium Web Driver does not work on xvfb

I want to run my Robot Framework tests which include Selenium2Library keywords on an Ubuntu remote machine so they should be run without a display. At first I just tried to run a simple test and get following result:
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
I installed xvfb in order the run headless tests and run these lines on remote shell:
sudo Xvfb :10 -ac
export DISPLAY=:10
Now i am getting the following error and I can't get rid of it
test | FAIL |
WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
I checked nearly all questions here about Selenium on xvfb and this specific error.
Since some mentioned about Selenium - Firefox incompability, I tried updating selenium (it is up to date, version 2.46.0), my Firefox was latest and i has not worked.
Then I tried using an old firefox relase (35.0) which is also not worked
Now I'm trying a solution for this problem and I am almost sure it is about fireofx.
Thanks for your answers and advices
EDIT:
->Runing tests with chrome works just fine
->Also i checked my iptables if there is a rule blocking network to local, it is in default state

Resources