Chromedriver does not respond on Centos 7 - selenium-chromedriver

Hi in a headless centos 7 I am trying to getting work headless selenium tests.
To do that I Installed google-chrome, chromedriver and selenium pip package but I have no success here is what I have done.
google-chrome version:
yum list installed |grep google-chrome
google-chrome-stable.x86_64 83.0.4103.106-1 #google-chrome
I downloaded chrome driver version 83.0.4103.39 from this link, unzip it and move it to the /usr/bin/local
-rwxr-xr-x 1 root root 10774816 May 5 23:53 chromedriver
and that path is in env as well.
PATH=...:/usr/local/bin/chromedriver:/usr/local/bin/
When I type chromdriver in the terminal nothing happens. It just stucks. I am behind corporate proxy so I can't really try to change firewall or etc. What am i doing wrong ?

Don't put binary executables on $PATH, but only directory /usr/local/bin.
You'll have to source the profile after editing it: . ~/.bashrc.
And you might have to configure it for headless mode:
options = webdriver.ChromeOptions()
options.add_argument('window-size=1920x1080');
options.add_argument('--headless')
options.add_argument('--incognito');
Also check for possible alerts there: sealert -a /var/log/audit/audit.log.

Related

How can I get chromedriver to work properly with chrome in wsl2?

I am trying to run automated tests on a repository forked from here. I haven't really worked with yarn or mocha before (or chromedriver) so I'm going off of what the instructions are saying.
I've set up Ubuntu 18.04 in wsl2 and installed google-chrome-stable and chromedriver both at version 99.0.4844.51 in /usr/bin/. I have yarn start running in one terminal and when I try actually run yarn test it gives me:
SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 94
Current browser version is 99.0.4844.51 with binary path /usr/bin/google-chrome-stable
I've tried upgrading chromedriver from here to version 100.0.4896.20 but it gives me the same error saying it only supports Chrome version 94. I'm having a hard time trying to find Google version 94 for linux, and I'll be happy either way, either upgrading the chromedriver or downgrading chrome.

How to develop Flutter web app on Windows Subsystems for Linux (Debian 10)

I would like to develop Flutter web app on Windows Subsystems for Linux (Debian 10). I followed this instruction. https://flutter.dev/docs/get-started/codelab-web
flutter channel beta
flutter upgrade
flutter config --enable-web
First, I input these commands in my terminal and all of them worked fine.
Second, I tried flutter doctor command and this is the result.
Downloading android-arm-release/linux-x64 tools... 2.1s
Downloading android-arm64-profile/linux-x64 tools... 1.8s
Downloading android-arm64-release/linux-x64 tools... 1.6s
Downloading android-x64-profile/linux-x64 tools... 1.6s
Downloading android-x64-release/linux-x64 tools... 1.5s
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.18.0-11.1.pre, on Linux, locale en_US.UTF-8)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT to that location.
You may also want to add it to your PATH environment variable.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (not installed)
[✓] Connected device (1 available)
! Doctor found issues in 3 categories.
I develop web app, so I don't need Android toolchain and Android Studio, but I need Chrome.
I think there are two ways.
install Chrome on WSL => I searched the Internet, but I couldn't find the way to do so.
user Chrome on Windows 10(not WSL) => I searched the Internet (for example:flutter chrome "windows subsystems for linux"), but I couldn't find the way to do so.
Could you give me any advice?
Try setting the environment variable CHROME_EXECUTABLE to the path of the Chrome executable installed on Windows, so Flutter can locate it.
Turns out, you just need to tell flutter where chrome.exe is located on your host windows machine!
One way to do this is to use GUI Apps, which unfortunately requires WSL version 2 and Windows 11. Read More
Making WSL and GUI Apps ready
If you don't already have wsl, run Powershell in Admin mode and run
wsl --install -d Ubuntu
sudo apt update
change the distro as you like
If you have, run these to make sure it's ready
wsl --set-default-version 2
wsl --update
wsl --shutdown
sudo apt update
Installing Google Chrome on WSL
Change directories into the temp folder: cd /tmp
Use wget to download it: sudo wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
Get the current stable version: sudo dpkg -i google-chrome-stable_current_amd64.deb
Fix the package: sudo apt install --fix-broken -y
Configure the package: sudo dpkg -i google-chrome-stable_current_amd64.deb
To launch, enter: google-chrome
You should be good to go
Running flutter doctor should mark web development as ready, and projects should run with this command:
flutter run -d chrome --web-renderer canvaskit
My WSL2(Windows 10 build 18363) did not recognise the environment variable CHROME_EXECUTABLE.
So, I also added the environment variable WSLENV to 'CHROME_EXECUTABLE/p'.
(https://adamtheautomator.com/windows-subsystem-for-linux/#Sharing_Environment_Variables)
Then, it works!

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.

Can't Connect to Pebble Emulator

while I was trying to test my app on Pebble Emulator using Pebble SDK 3.0, I met a connection problem. The Emulator is working normally, but my host machine can't connect to QEMU virtual machine. So, the app wasn't fired up. See followings:
> pebble build
> pebble --debug install --emulator aplite
[INFO ] Starting phone simulator...
[ERROR ] Could not connect to phone at localhost:12342. Ensure that 'Developer Connection' is enabled in the Pebble app.
I don't know how to do further debugging on this issue.
According to the developer docs if you aren't using the native version of Python (eg. you installed Python with Homebrew or you are using Pyenv, etc.) you need to do the following - with your new version of Python active:
> brew remove boost-python
> brew install boost-python --build-from-source
This fixed things for me.
If your emulator is in a system folder that requires sudo access you will have to type:
sudo pebble --debug install --emulator aplite
You can find where your pebble bin folder is located with
which pebble

Running Chrome WebDriver on a linux server with no display

I'd like to run automated tests using selenium2's chrome webdriver on a linux server.
I've already set up firefox to run on the server by using Xvfb (See http://www.semicomplete.com/blog/geekery/xvfb-firefox.html) and would like to do something similar with chrome. Is this possible?
I was facing the same challenge of setting a linux box with selenium + chromedriver,
and here's my notes:
Pre-reqs:
Install JRE to run the selenium jar
Install the selenium server
grab the jar file from https://code.google.com/p/selenium/downloads/list)
Install xvfb (you've seem to have already achieved this part)
Install google-chrome for your linux distribution
Download the chrome driver
You can grab it from here: https://sites.google.com/a/chromium.org/chromedriver/downloads
Install other selenium dependencies that you might need (but the above is the minimum to get chromedriver to work)
To run:
Run xvfb
Xvfb :1 -screen 5 1024x768x8 &
export DISPLAY=:1.5
Run the selenium server jar with ChromeDriver options.
It'll look something like this:
java -jar selenium-server-standalone-2.30.0.jar -Dwebdriver.chrome.bin=/path/to/google-chrome -Dwebdriver.chrome.driver=/path/to/chromedriver
The selenium server log should output something similar to this:
Mar 19, 2013 10:07:27 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.bin to {location of google-chrome}
Setting system property webdriver.chrome.driver to {location of chromedriver}
10:07:34.258 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
10:07:34.259 INFO - Version Jetty/5.1.x
10:07:34.259 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
...
Reference:
http://www.yann.com/en/use-xvfb-selenium-and-chrome-to-drive-a-web-browser-in-php-23/08/2012.html
Cheers!
According to SetEnvironmentProperty to ChromeDriver programatically you can do the following:
service = new ChromeDriverService.Builder()
.usingChromeDriverExecutable(new File("/path/to/chromedriver"))
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY",":20"))
.build();
Here is the documentation for withEnvironment
I haven't been able to find a way to do this programmatically for the ChromeDriver like you can with the FirefoxBinary.
I've submitted a improvement request which has a patch attached to allow this. You can see it here: http://code.google.com/p/selenium/issues/detail?id=2673
Edit:
You can see below response from Stephen on how to use this now the change has been merged.: https://stackoverflow.com/a/16619608/998442
I get what you are trying to do, but you probably just run selenium grid. It was made for automated browser testing. Works great on a server.
https://www.selenium.dev/documentation/en/grid/