Error running selenium ruby script through xvfb-run - ruby

What I'm trying to do
Use selenium and its ruby bindings to open chrome and read a value from the DOM. This portion works great however I need to run it on a linux server headlessly. Seemed easy enough so I ran it using xvfb-run using this command:
export PATH=$PATH:./bin
xvfb-run --server-arg="-screen 0, 1024x768x16" ruby script.rb
The first line adds the binary chromedriver to PATH and the second lines runs the script through xvfb. I got this working on an EC2 ubuntu box which is essentially a dev box. Everything is great.
Now comes time to run it on another EC2 ubuntu box using the same bash script. It spits out an error that the chromedriver binary couldn't be found. Odd since it worked fine on the other box. I checked, the binary is there. I manually add it to the path and run the bash script again, same error. After some troubleshooting and googling I found this:
https://code.google.com/p/selenium/wiki/ChromeDriver
This advises that the chromedriver needs to be symlink'd to /usr/bin/google-chrome. Again odd since it works fine on the other box and my local machine without this symlink. I symlinked it to this location and now this is the error I'm getting:
/usr/local/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.41.0/lib/selenium/webdriver/remote/response.rb:51:in `assert_ok': unknown error: Chrome failed to start: exited abnormally (Selenium::WebDriver::Error::UnknownError)
I've never gotten this on my local or dev box. Any ideas? Is this an issue with chromedriver, xvfb or the environment its running in? Some difference in the deploy box that would be different than the dev box I'm missing?

I figured this out. Misunderstanding the directions here. Installed google-chrome in /usr/bin and it worked.

Related

ChromeDriver stopped working after reinstall.. Worked fine before - no other changes made. (macOS)

I'm new to Selenium webdriver but the issue that I am running into does not seem like a common problem (looked everywhere for solutions for 4+ hours).
macOS High Sierra 10.13.2 - Selenium 3.13.0 [via pip3] -
ChromeDriver 2.40 [via web source] - Chrome 68 - Python 3.7
Here's what happened:
Initially chromedriver is in my Applications directory with .bashrc and .bash_profile including:
export PATH="$PATH:/usr/local/Cellar/python/3.7.0/bin:/Applications"
I was building a scraper in Python 3.7 everything is working fine executing from command line:
python3.7 scraper.py
I want to start running scraper.py from inside SublimeText3.
I copy chromedriver into /usr/local/Cellar/python/3.7.0/bin to be available for my python3 Sublime build system.
Doesn't work: something to do with it not being the original.
Accidentally deleted original.... So I remove all traces of chromedriver and redownload to Applications directory (original working conditions).
Now, I try to run again from command line and I'm getting Only local connections are allowed.
I try to execute chromedriver on the command line and I get bash: command not found. Even when I am in the Applications directory! Whereas before I could execute chromedriver from any directory.
Every solution online suggests that it's either a compatibility issue or a PATH issue but neither is the case.
Tried rebooting my system, reinstalling python, reinstalling Selenium, reinstalling chromedriver again, moving chromedriver/redirecting PATH, rebooting my system again, everything...
Any input would be greatly appreciated. I'm thinking it has more to do with the OS then anything else. But can't make heads or tails of this. Also wondering if using a virtualenv would be able to circumvent this issue?
UPDATE: To anyone experiencing a similar issue, I would recommend just using a virtualenv. This allows you to work in an isolated python environment without having to clutter up your system with global packages and potentially risking a bug in your system's configuration.

No output using vagrant Windows 10

I'm not sure if this belongs her or another site, so let me know and I'll remove it if not. So I'm attempting to install vagrant on a windows 10 machine. I have virtual box installed, I have a kali linux machine on it that I've used in the past. After using the msi to install vagrant, I rebooted as prompted. After reboot I verified vagrant was added to the path.
Issuing any vagrant command shows nothing in the output. I've tried passing -h and --version and nothing shows. Even running as admin and powershell gives no response. No hanging or freezing, just nothing in the response. Not even a command not recognized warning(more validation its in my path).
Can anyone help me find out whats going on and why none of the vagrant commands seem to respond?
OUTPUT EXAMPLE
C:\>vagrant init -h
C:\>vagrant --version
C:\>
im guessing its something to do with their latest 1.9.7 version? i installed 1.9.6 and it finally gives me some output.

'vagrant ssh' not working with the vagrant-multi-putty plugin

I am trying to run VirtualBox with Vagrant and the plugin vagrant-multi-putty. I am running Windows 10 and am following this guide. All the plugins and steps seem to work fine until I get to the “vagrant ssh” step. I get this error:
I did some googling and the recommended solution is usually to set the path correctly to putty.exe. You can do that like so:
set PATH=%PATH%;C:\Program Files (x86)\PuTTY
Even though the plugin seems to be installing right I can’t find the putty.exe file anywhere on my system. I tried downloading the binaries from here and manually adding them to C:\Program Files (x86)\PuTTY. Then I set the path like the example above. However, I am still getting the same error when I run "vagrant ssh".
Made the same misstake myself at first.
According to the installation instructions for https://github.com/nickryand/vagrant-multi-putty you are supposed to use:
vagrant putty
instead of "vagrant ssh"

Tor console output issue: running tor --hash-password gives no result

I'm following the blog post here.
I'm using a Windows machine, so I can't follow the exact steps. This is what I've done:
Installed the Tor Browser for Windows
Installed pytorctl
pip install git+https://github.com/aaronsw/pytorctl
Installed Privoxy
Attempted to use the Tor command line. I'm assuming it is the exe file in the directory "Tor Browser\Browser\TorBrowser\Tor"
tor --hash-password *mypassword*
Unfortunately, this command runs but there is no response.
If anyone has any suggestions, much would be appreciated. Do you think this could be a firewall issue?
Apparently this is a known bug that when your run tor.exe from the command line it is running but opens in a hidden window. To get around this, run the following: tor --hash-password *your_password* | more. Hopefully this works. See more about the issue here.

Running selenium tests in ruby with Jenkins

I'm trying to set up CI on my local machine running on Mac. To do so I use Xubuntu virtual machine, Jenkins, and some simple selenium tests. tests on github
I get fresh install of Xubuntu, where I install Jenkins using official manual.
In Jenkins I installed some plugins(git, ruby, rake, rbenv).
In job config I use rbenv wrapper(2.1.0) with ignorance of os versions, also I use this gemlist:
bundler,rake,rspec,selenium-webdriver,capybara
and running that job with
rspec spec
And when I run this job I recieve something like that for every test:
Selenium::WebDriver::Error::WebDriverError:
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)
full output is here
it looks like jenkins user have no access to display to run/see firefox.
Anyone know how to make it work?
We ran into this at work recently and actually opted for Capybara and set the driver to poltergeist. This seemed better than trying to figure out how to run FF on our VM's.
That said, we were able to get a small test suite running by following the instructions here
Answer was not so simple as I think.
The problem is that jenkins service has no access to displays (when it installed via native package). Thats why when I try to start Firefox it's throw me a error. try:
$ sudo su - jenkins && firefox
So it's need access to display to start browser successfully.
This is how I done it:
first of all I used answer form here where I changed to my local user.
Then I installed xvfb plugin to Jenkins, and in my build job preset display to '0' - which is my actual user display. with that option all my tests would run 'headless' but on actual display.
This could be not the best way to solve my problem, but it definitely works for me.

Resources