Unable to run headless chrome inside vagrant - google-chrome

I am trying to run unit tests in headless chrome(version 61).
I have mentioned the browsers as 'ChromeHeadless' in Karma.config and corresponding script has been added to package.json.
When I run the npm test command inside vagrant(using Ubuntu 64-bit), it gives me this error:
FATAL:nss_util.cc(632)] NSS_VersionCheck("3.26") failed. NSS >= 3.26 is required. Please upgrade to the latest NSS, and if you still get this error, contact your distribution maintainer.
I tried updating the NSS version by running the below command:
sudo apt-get install --reinstall libnss3 but still no luck.
Is there anything that I am missing or doing incorrectly?

Related

Unable to use correct ChromeDriver version

I am conducting QA automation testing. The code was running and working fine last week, but on restarting my computer over the weekend, it has stopped working with this error message:
Request failed with status 500 due to session not created:
This version of ChromeDriver only supports Chrome version 103
I assume it auto-updated Chrome when I restarted the laptop, as it's gone from version 103 to 105, which means I need to update my ChromeDriver.
I've done this before a few months ago, can't totally remember the steps I followed but I got it working. I possibly did something wrong then, as I can't seem to update ChromeDriver from 103 to 105.
I've tried to remove my current instance and reinstall the newer version by running:
npm uninstall chromedriver -g
npm install -g chromedriver --detect_chromedriver_version --scripts-prepend-node-path
Also tried the same having downloaded it from here:
https://chromedriver.storage.googleapis.com/index.html?path=105.0.5195.52/
and doing
npm install -g chromedriver --chromedriver_filepath=<PATH>
Also tried removing chromedriver from my package.json, doing an npm install, then adding it back in and doing an npm install. Each of these methods say they have installed the correct chromeDriver version (105.0.5195.52)
My package.json currently shows:
"dependencies": {
"chromedriver": "^105.0.0",
},
and when I do chromeDriver -v I see:
ChromeDriver 105.0.5195.52
Any ideas? If additional information is required please let me know. I know I could probably get around this by downgrading my Chrome version to 103, but I'd prefer to avoid that if possible.
On further investigation, I think it's something to do with selenium. Running my tests on their own works, but if I do selenium-standalone start and then run them, it's failing as above.
I've updated selenium by running:
npm install selenium-standalone#latest -g
npm install
Following that, when I try to start it, it's giving me an error that chromedriver is missing within the selenium node_modules folder.
A bit more investigation and I've found I also needed to run
selenium-standalone install
This did some updating, and then I was able to run
selenium-standalone start
All good now :)

NaCl helper process running without a sandbox! error when running npm tests

I'n having a problem when running some npm test. The error I'm receiving is: "NaCl helper process running without a sandbox!", which is true, as I'm running the browser with the "--no-sandbox" option. I have to run this option due to the fact that the browser runs as root, and I don't have an option to run it a different user at all(it's a docker image).
Can anyone please help me to sort it out?
P.S I'm installing the browser in the following way:
RUN apt-get update
RUN apt-get install -y nodejs npm
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
RUN apt-get install -y apt-transport-https
RUN apt-get update
RUN apt-get install -y google-chrome-stable
Thanks in advance!
This error message...
NaCl helper process running without a sandbox!
...implies that you have no setuid sandbox in your system, hence the program was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Solution
A quick solution will be, if you want to run Chrome and only use the namespace sandbox, you can set the flag:
--disable-setuid-sandbox
This flag will disable the setuid sandbox (Linux only). But if you do so on a host without appropriate kernel support for the namespace sandbox, Chrome will not spin up. As an alternative you can also use the flag:
--no-sandbox
This flag will disable the sandbox for all process types that are normally sandboxed.
Example:
chromeOptions: {
args: ['--disable-setuid-sandbox', '--no-sandbox']
},
You can find a detailed discussion in Security Considerations - ChromeDriver - Webdriver for Chrome
Deep dive
As per the documentation in Linux SUID Sandbox Development google-chrome needs a SUID helper binary to turn on the sandbox on Linux. In majority of the cases you can install the proper sandbox for you using the command:
build/update-linux-sandbox.sh
This program will install the proper sandbox for you in /usr/local/sbin and tell you to update your .bashrc if required.
However, there can be some exceptions as an example, if your setuid binary is out of date, you will get messages such as:
Running without the SUID sandbox!
Or
The setuid sandbox provides API version X, but you need Y
You are using a wrong version of the setuid binary!
In these cases, you need to:
Build chrome_sandbox whenever you build chrome (ninja -C xxx chrome chrome_sandbox instead of ninja -C xxx chrome)
After building, execute update-linux-sandbox.sh.
# needed if you build on NFS!
sudo cp out/Debug/chrome_sandbox /usr/local/sbin/chrome-devel-sandbox
sudo chown root:root /usr/local/sbin/chrome-devel-sandbox
sudo chmod 4755 /usr/local/sbin/chrome-devel-sandbox
Finally, you have to include the following line in your ~/.bashrc (or .zshenv):
export CHROME_DEVEL_SANDBOX=/usr/local/sbin/chrome-devel-sandbox
If you are using karma to run your tests, make sure you are using ChromeHeadless as the browser on karma.conf.js

Run Flash Webpage in Headless Chrome on Ubuntu 14.04

I am trying to run my Cucumber tests headlessly with Chrome on Ubuntu 14.04 (EC2 instance so no GUI). So far my setup allows this, as the below screenshot shows:
I have an issue when I come to a page with flash on it:
I have restarted the EC2 instance and killed all chrome processes, still no joy.
To clarify, a test will start and chrome opens the page with flash on it and I get this message. If I then end the test and start it again I get the same problem. I guess this is not actually restarting chrome as it is a new instance each time?
So to run these tests I am using the headless gem here which acts as the interface to xvfb.
I have Google Chrome 57.0.2987.133 and have added libflashplayer.so to /opt/google/chrome/pluginsusing this https://askubuntu.com/questions/14629/how-do-i-enable-the-partner-repository
A few extras things I have tried include:
sudo apt-get install pepperflashplugin-nonfree
sudo update-pepperflashplugin-nonfree --install
Is there a way to get this to work so I can render flash based sites? Do I need to enable the flash plugin each time I open chrome? I'm hoping I've missed something obvious.
Update
I have tried setting the pepperflashpluginpath when creating the Chrome profile but this is still not working:
Capybara.register_driver :chrome do |app|
chrome_binary = '/usr/bin/google-chrome'
Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => { "binary" => chrome_binary, "args" => ["--ppapi-flash-path=/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so"] })
Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => capabilities)
end
Thanks
There were three key parts in getting this to work.
Install Chromium Browser
sudo apt-get install chromium-browser (at time this installed version 58)
The Chrome binary is now installed at
/usr/bin/chromium-browser
Install Flash plugin
https://askubuntu.com/questions/531672/how-to-install-flash-payer-in-ubuntu-14-04-lts
First go to /etc/apt/sources.list and uncomment the lines
deb http://archive.canonical.com/ubuntu trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner
Then run
sudo apt-get update
sudo apt-get install adobe-flashplugin
This installs the flash plugin at
/usr/lib/adobe-flashplugin/libflashplayer.so
Install Chrome Driver
Then run
sudo apt-get install chromium-chromedriver
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/chromedriver
That's pretty much it, these were the steps that got me running this with Cucumber headless.

404 error when using brew to install mysql - macOS Sierra

This question has been asked before here (404 error when using brew to install mysql), but unfortunately the fix doesn't work for me. I have already ran brew update, so I'm up to date.
I'm on the latest version of MacOS 10.12 and I am running Xcode 8 if that matters.
brew install mysql
Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
==> Downloading https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz
curl: (22) The requested URL returned error: 404 Not Found Error:
Failed to download resource "mysql" Download failed:
https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.11.tar.gz
I know it says this is a pre-release version, but is there any hope here?
Thanks
The 5.7.11 mysql download you reference no longer exists (it certainly is 404).
Looking at the homebrew formula for mysql, it has been updated to point to the latest mysql version.
So it seems that you are not in fact up to date. Try running brew update twice, then brew doctor and fix any warnings.
There have been some big changes in homebrew over the last 9 months, if you have an old install it might be easier to uninstall totally. There are also several ownership and directory location changes that need to be straightened out with the upgrade to homebrew 1.0
I followed the steps laid out here: Brew Update not working after mac 10.9
In case that's not visible anymore, here's that answer:
cd `brew --prefix`
git fetch origin
git reset --hard origin/master
After that, you should be able to brew update and then brew install mysql
For those who are still struggling to resolve this.
Please try:
brew update-reset
brew update
I found this gem here.
P.S.: If you have a shallow clone, after brew update-reset command, run the following command to unshallow:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

OSX Lion Homebrew "brew install mysql -v" problems

I am working to install mysql locally using home brew and it keeps blowing up. When I run brew doctor I do not get any errors, and the full verbose output of attempting to install mysql is https://gist.github.com/2424859, ending with:
MAKEFLAGS: -j4
Error: Failed executing: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/mysql/5.5.20 -DMYSQL_DATADIR=/usr/local/var/mysql -DINSTALL_MANDIR=/usr/local/Cellar/mysql/5.5.20/share/man -DINSTALL_DOCDIR=/usr/local/Cellar/mysql/5.5.20/share/doc/mysql -DINSTALL_INFODIR=/usr/local/Cellar/mysql/5.5.20/share/info -DINSTALL_MYSQLSHAREDIR=share/mysql -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DSYSCONFDIR=/usr/local/etc -DWITH_UNIT_TESTS=OFF -DWITH_READLINE=yes (mysql.rb:77)
These existing issues may help you:
https://github.com/mxcl/homebrew/issues/8063
https://github.com/mxcl/homebrew/issues/9142
https://github.com/mxcl/homebrew/issues/11710
https://github.com/mxcl/homebrew/issues/11754
Otherwise, please report the bug:
https://github.com/mxcl/homebrew/wiki/reporting-bugs
. I am running osx lion, full xcode 4.3.2.
any ideas on what the primary issue is?
after posting on the homebrew github issues:https://github.com/mxcl/homebrew/issues/11762
here is how I fixed the issue:
cd /usr/local
brew uninstall cmake
git checkout 948c2769 Library/Formula/cmake.rb
brew install mysql