Jenkins setup for running Selenium test on Ubuntu - selenium

I already tried a lot for Jenkins setup on Ubuntu for running selenium test cases. But each time i face problem Like Display error , chrome connection timeout. I tried all the solution on internet (debugging this from last one week). Someone please help in setting up by step by step process (including version compatibility).
Also, test-cases on Ubuntu Jenkins run only on display mode?

Related

Cucumber selenium failing in jenkins pipeline only

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.

Slowness when running headless Selenium from Jenkins

I've spent about a day looking for solutions around the web to my issue but none work for me.
Here is my scenario:
I am running Selenium scripts with ChromeDriver using pyATS framework on my Ubuntu 18.04 VM. The VM has 4 GB of memory. I also have setup Jenkins on the machine and am trying to run the pyATS script with the pyATS plugin.
When running headless mode from the terminal, the script runs in the same or faster time than non-headless mode. However, when I run in Jenkins on the same machine, I am getting extreme slowdowns. It looks almost as if Jenkins is running my script in sections, with >2 minutes of delay in between steps at random.
I've tried out Xvfb, headless with various chrome options (noproxy, proxy options, gpu disable, etc), increasing heap memory for jenkins, but I always get the same random 2 min of delay in between script steps.
The script doesn't fail - it will complete eventually. But for a step that I expect to take around 2 min, jenkins will take 10 minutes.
I currently don't have a way to increase the memory my VM has, but are there any other solutions that I can try in the meantime?
Found the issue, I had to set the "--proxy-server" for Chrome to the proxy my VM was running behind. For some reason Firefox was working fine without that option so I didn't think to set this option for Chrome.

Selenium works when started locally, but not remotely

I'm hoping this is a simple issue to solve:
I have a dedicated machine that runs selenium with chromedriver. I can physically walk to the machine and type the following in a local terminal:
java -Dwebdriver.chrome.driver=chromedriver238 -jar selenium-server-3.11.jar
I can then go to any other machine on the network and kick off testing (in my case, codeception on jenkins) and it will sucessfully run my tests in chrome without a hitch.
However, if I try to run the above command without physically being at the selenium machine (ex, trying to ssh into the machine to run the command or making this command run as part of a supervisor process) then selenium has trouble starting the instance of chrome.
Has anyone run into this scenario before? Is there a way I can give 'interactive' access to the background script to allow it to open stuff on my screen?
Because when you physically walk to the machine and run the command. the selenium can get the desktop/window interface.
When use SSH, selenium lost the desktop/window interface, selenium have to start chrome under headless model, but your code not config to run as headless model. So the conflict come out.
you need to config your code to run with headless model.
I'm to getting the same scenario, when i try to start the selenium code on the machine A it works yet when i try to start selenium and run the scripts from machine B
(remotely connecting to machine A using ssh [ssh test#machine-a]) chrome instance doesn't start/launch and driver is getting null.
logs :
2020-02-27 12:04:27,319 INFO [LogWritter] Exception in beforeclass chrome driver instantiation , driver is null
2020-02-27 12:04:27,493 INFO [LogWritter] Exception in getting screenshot---java.awt.AWTException: headless environment
Any help/suggestion would be great !

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.

Jenkins with Xvfb and Selenium - Firefox started but nothing executed

I have a problem with Selenium under Jenkins 1.446 together with Xvfb: It looks like firefox is started correctly because I let my failing tests record screenshots. These screenshots all show the same failing page, which in my case is the starting page where the tests should begin. So I gues the selenium WebDriver commands do not arrive. What could be the reason? By the way, the tests are running perfectly on my local machine.
I'm using Firefox 9.0.1 with no specific test profile and no AddOns, Ubuntu 10.04, Senlenium 2.16.1
Log entry: com.thoughtworks.selenium.SeleniumException: Timed out waiting for action to finish
Thanks!
EDIT: Issue seems to be fixed by a system reboot ...
I experienced a very similar issue with FF9.0.1 and Selenium 2.16.1 running through JUnit launched by Maven SureFire plugin run by Jenkins on a WinXP node.
2.17.0 fixed the issue for me. Try updating to the latest Selenium.
Through RDP, I was able to watch the tests running. The tests appeared to be partially blocked by a prompt from Firefox asking about collecting anonymous usage statistics. Manually answering the prompt would allow the test to continue but because Selenium creates a new profile each time by default, the prompt would return on the next browser launch. Running the tests locally with a pre-configured FF profile allowed me to persist that the prompt had been answered. This isn't possible on my XP node because the tests are running as 'System'.
Selenium/WebDriver would normally take care of this for you by marking the prompt as already answered in a temporary FF profile configuration but a bug was causing the value to be set to the wrong value. You can inject a profile configuration to the Selenium FirefoxDriver driver to pragmatically configure stuff like this prompt but the bug appeared to prevent this as well. This has been resolved in Selenium 2.17.0 (http://selenium.googlecode.com/svn/trunk/java/CHANGELOG see 2.17.0 WebDriver bug fixes).