Jenkins with Xvfb and Selenium - Firefox started but nothing executed - testing

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).

Related

Selenium chromedriver that does not depend on current Chrome installation

Due to organization policy, the Chrome browser installation on my Windows Server machine is automatically updated. I have some processes that rely on python Selenium and chromedriver. Because of this, my process breaks whenever my org decides to push out an update.
Is it possible to have chromedriver depend on some binary other than Chrome browser that will not be managed by my organization so that this doesn't happen?
Few of the workarounds to resolve the issue:
We have kept the chrome exe file in an artifactory and we download and install that particular chrome version every time before our execution through automation (our requirement is like that).
As #Corey is suggesting you can webdrivermanager, PFB link for more details
https://github.com/bonigarcia/webdrivermanager
You can try Dockerized Selenium, there you'll have the control in the docker-compose.yml file.

Firefox spontaneous launch in Selenium

Environment:
selenium-server-standalone-3.8.1.jar
geckodriver-v0.24.0
firefox 60.6.1
Everything was set up 6 months ago and everything worked well, the tests passed through the Selenium and there were no problems.
Since 08/23/2019 problems began. Without any launches test inside the Selenium process, started to run spontaneously browsers (firefox) and did not turn off.
These processes overload the processor on the server, after which the server starts to brake and also the site that is on the server. These "browser launches" continue until Selenium is reloaded by open browsers after which our automatic tests are blocked and display an error: "unable to create new native thread".
As soon as one such browser spontaneously opens, the processor load becomes 100%.
These browser launches occur approximately 1 time in 4-5 minutes.
All tests are disabled, but Selenium lives its own life, and continues to launch the browsers.
Maybe someone faced a similar problem? Any ideas why this is happening and how to fix it?
The launch of selenium occurs on command:
su screener -c "/usr/bin/java -Dwebdriver.gecko.driver=/usr/local/bin/geckodriver -jar /usr/lib/selenium/selenium-server-standalone-3.8.1.jar -enablePassThrough false -port 4444 >/var/log/selenium/selenium_std.log 2>/var/log/selenium/selenium_error.log &"
Term yourself lucky to have sailed smoothly with geckodriver-v0.24.0 and selenium-server-standalone-3.8.1.jar till 08/23/2019.
As per the documentation:
To work with geckodriver-v0.24.0 you need:
Selenium Python client version greater then 3.14
Firefox client version minimum 57 (which seems to be okay)
You can find the detailed GeckoDriver, Selenium and Firefox Browser compatibility chart in the discussion Which Firefox browser versions supported for given Geckodriver version?
Additional considerations
As a part of the best practices:
Upgrade JDK to recent levels JDK 8u222.
Upgrade Selenium to current levels Version 3.141.59.
Upgrade GeckoDriver to GeckoDriver v0.24.0 level.
GeckoDriver is present in the desired location.
GeckoDriver is having executable permission for non-root users.
Upgrade Firefox version to Firefox v65.0.2 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
http://www.yourownlinux.com/2013/10/how-to-free-up-release-unused-cached-memory-in-linux.html) before and after the execution of your Test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your Test as a non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
You can find a detailed discussion in PhantomJS web driver stays in memory
If the stale WebDriver instances still persist you may require to forcefully remove them.
You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?
Outro
Limit chrome headless CPU and memory usage

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 !

Selenium WDS executeScript()

I have a strange problem, which I'm unable to solve for sometime. I have a selenium WDS for Firefox browser. I tried to execute the code in JMeter UI, everything works fine. But when I try to execute the same in a server (using XVFB driver), I get the error:
rm="sun.org.mozilla.javascript.EvaluatorException: Can&apos;t find method org.openqa.selenium.remote.RemoteWebDriver.executeScript(string,org.openqa.selenium.remote.RemoteWebElement). (<Unknown source>#17) in <Unknown source> at line number 17"
All the required drivers are the same as the one I locally try. Yet, I get the error only when I run in the server but not locally. Please help
Most probably you have different versions of either WebDriver Sampler or dependency libraries, I don't see any other ways for the same script to work on one machine and don't work on another.
Install the same version of JMeter onto both machines (use JMeter 3.2 or later, whatever is available at JMeter Downloads Page)
Install latest version of the WebDriver Sampler plugin using JMeter Plugins Manager
Your test should now be running fine.

Unable to run WebDriverIo tutorial

I'm trying to follow the WebDriverIo tutorial at http://webdriver.io/guide.html .
After setting up the Selenium server, when I try executing the test node script (step 7 in the tutorial), selenium warns me of some errors (see screenshot for full log), and I don't get any output returned.
Steps to reproduce:
I start the Selenium server
When I try running the node script, this happens (clock to zoom):
At this point a Firefox window opens automatically, and remains blank.
I'm running Firefox v52 and Selenium 3.0.1. I downloaded Geckodriver from https://github.com/mozilla/geckodriver/releases
Any obvious thing that I'm missing? I'm very new to Selenium and browser automation, forgive the generic input :)
If you have been here to get your Windows release of gecko driver : https://github.com/mozilla/geckodriver/releases, you may have miss this message :
"IMPORTANT: If you use geckodriver with Selenium, you must upgrade to
Selenium 3.3 since this release aligns HTTP responses with the
WebDriver standard."
(I can see you are in v3.0.1).