Cucumber selenium failing in jenkins pipeline only - selenium

I am working on an integration test, using Selenium/Java/Cucumber. When I run the test on localhost, or remotely on a VM, it passes fine. But when it runs as part of a Jenkins pipeline it hangs with the error "Timed out receiving message from renderer". I have googled this and there are several possible causes, including version conflicts. But I can't seem to figure out how to check these versions in the jenkins pipeline. Any pointers on what to look into would be helpful. I believe the tests are running headless on the pipeline, because there is no Chromedriver pluigin installed in our Jenkins. The test is pretty straightforward - it involves clicking on an element within an iframe (this is where it hangs) and checking for some output. I have even tested it running manually on the VM created by the very same pipeline and it always works without an issue.

Related

Running webdriver IEDriver on Jenkins fails

I have a small C# webdriver test suite dll which I recently created...
Runs fine in Visual Studio
Runs from the command line perfectly using the NUnit 3 console runner.
I have Jenkins installed on my laptop (for testing before I put it into my live Jenkins), running with my Windows credentials. When I execute the test suite using the same NUnit3 console runner command I used before, all the tests fail, can't even log in as it can't find any elements. I took screenshots with Selenium & it's just a black rectangle!
Anyone have any ideas on how to get IE behaving - I bet it's a Windows permissions thing from Jenkins. Thanks!
I'll answer my own question.
Turns out you can't do what I'm attempting - it's a known issue with the way IE is built. What I had to do is install a new Jenkins node on another machine and get that to run the IE tests. That way it did work.

Setting up selenium, chromedriver, and wdio mixed with vagrant or docker

I started out trying to learn how to write automated tests for a small project but nothing was working right out of the box. After a couple hours of searching & experimenting I found the right configuration for my project & figured sharing it might help folks in the future.
Here's a small summary of the errors I encountered on this debugging journey:
Using Jasmine & WDIO, send_keys was crashing
It was a Firefox/geckodriver bug, or something like that
WDIO appeared to hang after switching from Firefox to Chrome
Chrome needed to be run in --no-sandbox mode, essentially
I figured my problem was probably stemming from having WDIO execute my tests on my local machine while Selenium was hammering on the browser in a Vagrant VM. So this will mainly be applicable for people using separate environments (vagrant->local, vagrant->vagrant, docker->local, etc) for WDIO & Selenium/Chromedriver. Here is a gist of the configuration file I ended up with.
I started with fanatique/vagrant-selenium-vm and modified it to use Chrome instead of Firefox because send_keys was broken with Firefox/geckodriver at the time of writing. After swapping out the packages, I'd start the tests with wdio but it would appear to hang. Turning on verbose logging showed it trying to start but failing with no explanation why.
[00:06:39] COMMAND POST "/wd/hub/session"
[00:06:39] DATA {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"browserName":"chrome","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.6.2","name":"webdriverio"}}}
It took removing the & from the nohup java ... command in fanatique/vagrant-selenium-vm's setup.sh to see the logs from Selenium in real time, then I was able to see a "only local connections are allowed" message from chromedriver. That led me to a SO post that said to add --whitelisted-ips="" as an arg to chromedriver - but I was still getting the local connections error message. Chrome itself ended up needing a --no-sandbox flag - that allowed WDIO to connect to the chromedriver in Selenium and my tests ran from there.

When selenium test runs by Jenkins and MSUnit, the browser doesn't come up however there are valid results

I put together a machine (Windows Server 2012R2) for POC reasons where a Jenkins installed and it executes Selenium UI tests using msunit
But, when I log in the server where the Jenkins runs and I watch what happens during CI build (compile and test execution) I can't see that the browser (Firefox) starts automatically, however, the test results and the logs show that a browser was executed.
My question is that, what the is happening when my tests are executed by Jenkins? If I execute the command which from visual studio on the same machine then I can see that Firefox starts, does what is programmed in the tests and the results are in the result.trx.Can I somehow set up Jenkins the way the browser really executed (I can believe it when I see it :)
In Jenkins when you run selenium test cases, they are executed in the background by default.
Your Jenkins might be configured to run those test cases in some video buffer(usually it happens on Linux but can also be configured on Windows) or in a headless state.
As your question, if you are using MSTest which basically used to convert the test cases result from trx to JMX format but also can be used to run selenium tests. when you run the same in Jenkins it will run in background on any slave or on master.

Selenium with Xvfb and Jenkins throws TimeoutException

I'm trying to setup automatic Selenium tests with Jenkins on a Linux server.
The problem is that all tests fail with:
org.openqa.selenium.TimeoutException: Timed out after 60 seconds waiting for visibility of element located by By.linkText
Each test fails with the fist element expected.
Jenkins has the Xvfb plugin installed, and from the console messages it seems to work:
Xvfb starting$ /usr/bin/Xvfb :1 -screen 0 1024x768x24
I tried to increase the timeout, but it seems its not that the problem.
The tests run fine on windows and on a linux system with display.
The problem is I don't have direct access to the server, so I'm trying to explore all possibilities before I make requests to the sys admins.
To run the tests are used two projects, both seem to deploy fine, but when the tests start its like one project (the backend) is not deployed and some URLs are not found, from here the timeout exception. I'm not very sure how Jenkins behaves in this case, and if it starts one project at a time.
Any ideas? Thanks a lot!
To check if the application under test is running when tests try to access it, you can connect to the test machine via ssh, and take screenshot at the moment when the test runs:
xwd -root | convert xwd:- capture.png
http://inspirated.com/2007/04/02/howto-use-xwd-for-screenshots

Selenium server cannot be started inside Bamboo

I am trying to configure a Selenium testing through Bamboo. I am able to run Selenium scripts directly from command line, however it always fails if I run it through Bamboo remote agent. The error is:
: Could not start Selenium session: Failed to start new browser session: Error while launching browser
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:107)
I took some advice from the web, and checked "Allow service to interact with desktop" for Bamboo remote agent service. However, it does not work.
Anyone have other suggestions?
You must run Bamboo in Console Mode for this to work. Also, the build machine desktop must be active - and not covered or minimized if you want mouse simulations to work. I know right!