How to run testcafe tests from my MAC in Saucelabs? - testing

I tried to run with the below command in the command line.
export NODE_ENV=default | npx testcafe "saucelabs:Chrome#81.0:macOS 10.14" './testCafeTests/userStoryTests/createRoute.js'
With my credentials, it is able to connect to sauce, but the browser is not navigating to the URL mentioned in my test.
Can someone please help?

I found out the solution of how to run these test . We need to mention the hostname and ports in the command line arguments to run these test in saucelabs.
export NODE_ENV=default | npx testcafe "saucelabs:Chrome#81.0:macOS 10.14" './testCafeTests/userStoryTests/createRoute.js --hostname=localhost --port=8000,8001

Related

“ERROR Unable to find the browser. “saucelabs:Chrome#83.0:Windows10” is not a browser alias or path to an executable file

I am trying to run my UI test using testcafe and saucelabs. I am facing this above error. Currently I am using testcafe v1.8.3 and testcafe-browser-provider-saucelabs v1.7.0
I have tried changing versions of browser provider also but still facing the above error. Pls help out with a solution for this as i am stuck with it for more than a week
So, it looks like the runner you are using (testcafe-browser-provider) is a very old one, there is a new runner you can use for testcafe tests called saucectl.
TLDR:
Install saucectl globally npm install -g saucectl
Set up saucectl within your project folder with saucectl init This will create a .sauce/config.yml file
Tweak the settings to run the spec files and OS/ browser of your choice
Use saucectl run
You can see an example proj here: https://github.com/saucelabs/saucectl-testcafe-example
It looks like your provider is installed locally, while you are using the global TestCafe installation. You also need to install TestCafe locally or both packages globally. After this, check your browser provider: testcafe -b saucelabs.
I am using testcafe v1.8.3 and testcafe-browser-provider-saucelabs v1.7.0
Please update your testcafe and testcafe-browser-provider-saucelabs versions to the latest ones.

Allure tries to run a report on a wrong port in intelij idea and npm

I have allure setup in our work project. At work it runs fine and command "allure generate ./allure-results -c && allure open", generates a report and runs it autmaticaly in browser. But at home when i run this comand it opens a browser page with no internet. But if i manualy run index.html from allure folder with browser it works fine. The only difference is : utomaticaly it tries to run on http://172.200.101.123:65249 and from ide manualy it runs on http://localhost:63342/
As far as i understand, default allure's ip and port is blocked by windows and i don't know how to unblock them. so i found a workaround: tell allure to run a report on a localhost like this:
allure serve target/allure-results --host localhost --port 9999

How to generate mocha test case report and show using Jenkins?

I am doing mocha unit testing for my JavaScript functions. I am running mocha in a browser not using Node. I am using require.js to load files.
When I do mocha.run() it shows reports in the browser.
Now I want to make a Jenkins job to display the report.
So how do I generate the report file so that I can provide it to Jenkins?
Running the command:
$ npm install mocha-junit-reporter --save-dev
Will generate an XML file that you can give to Jenkins
Run the command
$ mocha ./test.js --reporter mocha-junit-reporter --reporter-options ./test-results.xml
For docker file use below command
CMD ["mocha", "./test.js" , "--reporter", "mocha-junit-reporter", "--reporter-options","./test-results.xml"]
Both command will do the same.
test-results.xml file be generate in the folder .
I am answering my own question, I have solve this problem by using NGINX server which is open source.
I have added form tag in index.html of mocha and wrote on function on submit form to run mocha suit, this will return you output , parse that output and make file of that according to your need like total success count, failure count etc. and gave to Jenkins.

Testing website in nightwatch without browser

is any chance to test website by url and do not open browser so any info output will be in the command line?
Thanks in advance !
You could use PhantomJS if you just don't want to run a browser but it sounds like may just want to see the output, have you tried running with the --verbose flag?

Selenium+Jenkins+Chromedriver = WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

I have problem with running my Selenium tests in Jenkins.
A result of execution is always:
WebDriverException: Message: unknown error: Chrome failed to start:
exited abnormally
My tests are written in Robot Framework and are using Chromium webdriver.
I'm setting needed paths in my command, which looks like this:
export PATH=$PATH:/usr/lib/chromium-browser; export PATH=$PATH:/usr/lib/chromium-browser/chromedriver; . /home/michal/robot_env/bin/activate; robot -L TRACE /home/michal/project_robot/tests
And when I run this command manually in terminal IT WORKS fine (Chromium starts automatically and the test goes on).
So the problem suppose to be in Jenkins. I have installed Xvfb plugin, but it didn't help.
Additionally, in /etc/init.d/jenkins I put these lines:
/usr/bin/X :0 vt7 -ac
export DISPLAY=:0
xhost +
And once again - nothing changed. What else should I set or check?
i got stuck same way.
The problem is that jenkins has it own user, called jenkins, and jenkins user cannot open the browser.
if you try to make "su jenkins" and then "chromium-browser" you obtain the display error.
That because you obtain this issue. The problem is not the webdriver, the problem is the user.
i removed the jenkins user created by jenkins and i createad a normal user called jenkins before installing jenkins.
then i installed jenkins.
now jenkins user can run the test (because it can open the browser) but jenkins itself will not load anymore.