headless watir webdriver tests unable to find firefox - ruby

I am setting up watir-webdriver tests on gitlab ci ubuntu image using docker. I am installing firefox from mozilla site and then trying to run the tests. However, I keep getting the error that selenium is unable to find firefox
No such file or directory - /usr/bin/firefox (ChildProcess::LaunchError)
The steps that I followed to install firefox
$wget https://ftp.mozilla.org/pub/firefox/releases/35.0/linux-i686/en-US/firefox-35.0.tar.bz2
$tar xjf firefox-35.0.tar.bz2
$cp -r firefox /opt/firefox35
$ln -s /opt/firefox35/firefox /usr/bin/firefox
I tried changing the sym link path to /usr/bin/firefox and /usr/local/firefox
I also tried setting the path to firefox explicitly in env.rb
Selenium::WebDriver::Firefox::Binary.path = '/usr/local/firefox'
Selenium::WebDriver::Firefox::Binary.path = '../firefox/firefox'
I am facing the same issue even with the newer versions of firefox.
I also tried installing firefox using the apt-get package manager with same result.
Did any one face this issue and was able to resolve it?

Related

Gatsbyjs Local HTTPS getting browser security errors

I'm trying to set up local https with gatsbyjs. I followed gatsby's instructions including setting up Certutil via brew install nss.
I then run, $ npm run develop -- --https.
When I open https://localhost:8000/ in Chrome I get ERR_SSL_PROTOCOL_ERROR and in Firefox I get Error code: SSL_ERROR_RX_RECORD_TOO_LONG.
Any help on this would be appreciated.

unable to connect to chromedriver 127.0.0.1:9515. Amazon Linux AMI

I am setting up my selenium-webdriver tests with Linux and working on automating my tests with Cron Jobs. When running my script I am receiving this error
Selenium::WebDriver::Error::WebDriverError:
unable to connect to chromedriver 127.0.0.1:9515
which chromedriver returns:
/usr/bin/chromedriver
and which google-chrome-stable returns:
/usr/bin/google-chrome-stable
I thought that the error was related to not having Chrome installed yet, so I did that, but has not seemed to fix my issue.
How can I work through this?
Thanks!
Firstly, locate your chromedriver (possibly /usr/bin) and check your dependencies:
ldd /usr/bin/chromedriver
It is likely you'll be missing at least libgconf-2
If this is the case, try this to resolve: https://forums.aws.amazon.com/thread.jspa?threadID=229187

Install chromedriver using a remote host

I deployed my application using Ruby, Sinatra and Redis DataBase, on my ubuntu remote host named Scaleway.
In this way, i've install all what i need, and i can acces to my application. So when i want to use my script, who use Watir gem (selenium), it's always show me this error :
Selenium::WebDriver::Error::WebDriverError at /show_result
unable to connect to chromedriver 127.0.0.1:9515
I know that i need Xvfb (who is installed), the headless gem (that i implemented in my code), and chromedriver that i installed by the same way that i installed it on my local machine.
On my local machine, it works perfectly, but in my remote host, it show me this error above.
Did you know how to fix this problem ? How did you install Chromedriver so that my program recognizes it ?
Did you run the watir command using xvfb with something like this
xvfb-run <here is your command>
Also Chromedriver should place properly so it can be access anywhere, usually I put chromedriver at /usr/bin/ or /usr/sbin/

how to add the missing RANDR extension

I have setup the xvfb server on my headless server and when I m running the
DISPLAY=:99 firefox
I am getting this exception missing RANDR extension
Many of them said to disable some xinerna from the xorg.conf file but this file is not getting created in my case.
So I am searching for how to add the missing RANDR extension.
I am seeing this error message when I run Firefox headless through selenium using xvfb. It turns out that the message was a red herring for me. The message is only a warning, not an error. It is not why Firefox was not starting correctly.
The reason that Firefox was not starting for me was that it had been updated to a version that was no longer compatible with the Selenium drivers that I was using. I upgraded the selenium drivers to the latest and Firefox starts up fine again (even with this warning message about RANDR).
New releases of Firefox are often only compatible with one or two versions of Selenium. Occasionally Firefox is released with NO compatible version of Selenium. When that happens, it may take a week or two for a new version of Selenium to get released. Because of this, I now keep a version of Firefox that is known to work with the version of Selenium that I have installed. In addition to the version of Firefox that is kept up to date by my package manager, I have a version installed in /opt/ (eg /opt/firefox31/). The Selenium Java API takes an argument for the location of the Firefox binary to be used. The downside is that older versions of Firefox have known security vulnerabilities and shouldn't be used with untrusted content.
First off, Xvfb doesn't read configuration from xorg.conf. Xvfb is a variant of the KDrive X servers and like all members of that family gets its configuration from the command line.
It is true that XRandR and Xinerama are mutually exclusive, but in the case of Xvfb there's no Xinerama in the first place. You can enable the XRandR extension by starting Xvfb using at least the following command line options
Xvfb +extension RANDR [further options]
I had the same problem with Firefox 30 + Selenium 2.49 + Ubuntu 15.04.
It worked fine with Ubuntu 14 but after upgrade to 15.04 I got same RANDR warning and problem at starting Firefox using Xfvb.
After adding +extension RANDR it worked again.
$ vim /etc/init/xvfb.conf
#!upstart
description "Xvfb Server as a daemon"
start on filesystem and started networking
stop on shutdown
respawn
env XVFB=/usr/bin/Xvfb
env XVFBARGS=":10 -screen 1 1024x768x24 -ac +extension GLX +extension RANDR +render -noreset"
env PIDFILE=/var/run/xvfb.pid
exec start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --exec $XVFB -- $XVFBARGS >> /var/log/xvfb.log 2>&1

unable to connect to chromedriver http://127.0.0.1:50299 (Selenium::WebDriver::Error::WebDriverError) [duplicate]

I get this error when I run my cucumber tests:
"*Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using Chrome binary at: /opt/google/chrome/google-chrome (Selenium::WebDriver::Error::UnknownError)
*"
I downloaded the chromdriver, unzip it, copy it to the path (/opt/google/chrome/google-chrome ) and sudo chmod +x /opt/google/chrome/google-chrome.
which google-chrome : /usr/bin/google-chrome
which chromedriver : /usr/share/ruby-rvm/gems/ruby-1.9.2-p318/bin/chromedriver
capybara (1.1.2)
cucumber (0.9.4)
cucumber-rails (0.3.2)
selenium-webdriver (2.20.0)
I searched my error but none of the answers worked for me!
When I run my test I do not see chrome starts!
I really dont know what is wrong! I tried two different versions of chromedriver!
Jenkins should run/executes my tests in CI.The tests work when you run them but not when Jenkins runs them? I could run them by another user and then I installed jenkins and I get this error. I get the same error when I run my tests in terminal at terminal as well.Did you read https://wiki.jenkins-ci.org/display/JENKINS/My+software+builds+on+my+computer+but+not+on+Jenkins ? I couldnt find much about my problem here. xvfb: I installed the plugin in the jenkins but in the build environment if I click "run xvfb before the build and shut it down after", I get this error: "FATAL: null java.lang.NullPointerException"
Please provide more details. How does this question relate to Jenkins? Is Jenkins executing the tests? The tests work when you run them but not when Jenkins runs them? You do not go so far as to say that out loud, but I will assume it because it is what people usually need help with.
Did you read https://wiki.jenkins-ci.org/display/JENKINS/My+software+builds+on+my+computer+but+not+on+Jenkins ?
If you are executing Chrome inside a Jenkins job, do you have something like https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin or https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin installed?
chromedriver can be installed in two ways: downloading, decompressing the zip and putting the file in "/usr/bin" or adding the "chromedriver-helper" gem in your Gemfile.
Choose one or another way because doing both many time it causes problems. If you are installing chromedriver from google, be sure to uninstall the gem:
gem uninstall chromedriver-helper
and be sure chromedriver is in your path:
which chromedriver
Give this a try instead => https://github.com/flavorjones/chromedriver-helper
Finally I found the answer:
if you want to run GUI tests on Jenkins CI running on Windows do not
configure it as a windows service instead run it from the command
prompt or set it up as a scheduled task to run on windows logon using
the command “java -jar jenkins.war”
taken from this article

Resources