How to get Chrome fullscreen with selenoid vnc - selenoid

I'm having trouble seeing a fullscreen browser when using VNC with selenoid.
I'm running in docker on a linux vagrant VM. I'm using the default commands to start the containers...
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}:/root -e OVERRIDE_HOME=${HOME} aerokube/cm:latest-release selenoid start --vnc --tmpfs 128
docker run -d --name selenoid-ui --link selenoid -p 8080:8080 aerokube/selenoid-ui --selenoid-uri=http://selenoid:4444
This is my C# code that initializes the remote webdriver...
var chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("--start-maximized");
chromeOptions.AddArguments("--disable-extensions");
var desiredCapabilities = chromeOptions.ToCapabilities() as DesiredCapabilities;
desiredCapabilities.Platform = new Platform(PlatformType.Any);
desiredCapabilities.SetCapability("enableVNC", true);
_currentWebDriver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), desiredCapabilities);
What could be the issue here?

This is because in current images we have no window manager. As a workaround you can set window size explicitly.
driver.manage().window().setSize(new Dimension(1920, 1080));
Currently we are working on fixing this issue. The following PR adds Fluxbox window manager. We hope to rebuild all images during next weeks.

Related

Issue connection Selenoid GGR (Go Grid Router)

I am trying to run nightwatchjs test using selenoid ggr (Go Grid router) but I am getting the below error:
- Connecting to un:pwd#ip_add on port 4444...
POST http://un:pwd#ip_add:4444 /wd/hub/session - EAI_FAIL
Error: getaddrinfo EAI_FAIL un:pwd#ip_add
‼ Error connecting to un:pwd#ip_add on port 4444.
Below are the various container that's running on my Linux machine (IP_add)
Could you please support in identifying the issue?
Also, I am unable to navigate to ggr-ui
I was now able to run the test using GGR.
Following command were run to start selenoid, ggr, ggr-ui and selenoid UI:
./cm selenoid start --vnc --port 4445
docker run -d --name ggr -v /etc/grid-router/:/etc/grid-router:ro --net host aerokube/ggr:latest-release
docker run -d --name ggr-ui -p 8888:8888 -v /etc/grid-router/quota/:/etc/grid-router/quota:ro aerokube/ggr-ui:latest-release
docker run -d --name selenoid-ui --link ggr-ui -p 8080:8080 aerokube/selenoid-ui --selenoid-uri=http://ggr-ui:8888
To navigate to ggr dashboard:
http://'ip address':8080/
In nightwatch config use following selenoum config:
host: '192.168.5.241',
port: 4444,
'username': "test",
'access_key': "test-password",
start_process: false,
This way I was able to run the test
Well, to run tests on GGR for me was enough official documentations
https://aerokube.com/ggr/latest/
I configured 2 machines
On machine №1 (where was configure ggr + ggr(ui))
You can see my list of configured containers
list of containers screen
On machine №2
Was configured Selenoid and Selenoid UI
Also do not forget to configure quota file(see official documentation)
See common screen of configuration:
screen of common configuration

How to point RemoteWebDriver to one of the multiple standalone docker selenium standalone chrome browsers?

I've requirement to run test cases on separate chrome browsers running inside docker container.
I've install chrome docker containers as below
docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-francium
docker run -d -p 4444:4444 -p 5901:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-francium
I have scripts which does unique tasks like analytics testing, performance testing etc so I can't use Grid approach here.
This is what I do in case of single chrome browser but I need to point to a particular docker container image
WebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"),
DesiredCapabilities.firefox());
Got it working with help of comment from #Flore B.
docker run -d -p 5902:4444 -p 5903:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.8.1-francium
RemoteWebDriver url
http://0.0.0.0:5902/wd/hub

Chrome driver throwing "org.openqa.selenium.remote.SessionNotFoundException" when running selenium tests heedlessly in linux?

Environment: Centos7, Chromedriver2.24, chrome-browser-stable version 2.53, selenium version 2.53.1 and xvfb
When running tests parallel with 8 concurrent threads giving session not found exception..
Chrome-setup:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList(
"--disable-logging", "--silent", "--log-level 3"));
capabilities.setCapability("chrome.logfile", "NUL");
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
System.setProperty("webdriver.chrome.driver",
"servers/chromedriver-local");
driver = new ChromeDriver(capabilities);
Any help much appreciated!!
This is what fixed my issue:
Simpy mount -v /dev/shm:/dev/shm
Or, longer, create a big shm
Started in privileged mode: docker run --privileged
Fix small /dev/shm size
docker exec $id sudo umount /dev/shm
docker exec $id sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
However it would be nice to avoid privileged mode.
(Ref:github.com/elgalu/docker-selenium/issues/20)

Getting WebDriver working with Firefox

Using Laravel 5+ with Vagrant.
I have selenium running using:
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.firefox.bin="/usr/bin/firefox"
using a headless display:
sudo Xvfb :10 -ac
However when i run codeception:
./vendor/bin/codecept run selenium --steps
I get the following error:
[Facebook\WebDriver\Exception\UnknownServerException] Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: GDK_BACKEND does not match available displays
I am confused with server and ports that i should be using.
Currently i access site through http://localhost:8000
however that is outside vagrant.
I observe $url = 'http://localhost:4444/wd/hub', inside api\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php
As the error outputs :
127.0.0.1 on port 7055.
Actually you should download latest geckodriver from here and set property Dwebdriver.gecko.driver with downloaded geckodriver path from your system when you run the selenium-server-standalone.jar as below :
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.firefox.bin="/usr/bin/firefox" -Dwebdriver.gecko.driver = "path/to/downloaded geckodriver
Note : Just like the other drivers available to Selenium from other browser vendors, Mozilla has released an executable geckodriver that will run alongside with the latest firefox browser. For more information you should follow this link.
Now you need to set capability with marionette to true during initialisation of RemoteWebDriver inside api\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php as :
$capabilities->setCapability('marionette', true);
Full example code :
$host = 'http://localhost:4444/wd/hub';
$capabilities = DesiredCapabilities::firefox();
$capabilities->setCapability('marionette', true);
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
Switched to chrome web driver, was less complicated, more compatible and works fine for me.
Download chrome webdriver or composer require
Setup environment
nohup sudo Xvfb :10 -ac &
export DISPLAY=:10
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver"

How to implement chromedriver in selenium in Linux platform

Can somebody tell me how to use the Chrome driver in Selenium for Linux platform?
I have my chrome driver location at username/home/chromedriver.
My code is:
System.setProperty("webdriver.chrome.driver", "/home/username/ChromeDriver/chrome‌​driver");
driver = new ChromeDriver();
driver.get("facebook.com");
The error I am getting is:
org.openqa.selenium.WebDriverException: 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
(WARNING: The server did not provide any stacktrace information)
From [the official documentation](https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver:
Requirements
The ChromeDriver controls the browser using Chrome's automation proxy
framework.
The server expects you to have Chrome installed in the default
location for each system:
OS Expected Location of Chrome
-------------------------------------
Linux /usr/bin/google-chrome
Mac /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
Windows XP %HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe
Windows Vista C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. See also the section on overriding the Chrome binary location.
Getting Started
To get set up, first
download the
appropriate prebuilt server. Make sure the server can be located on
your PATH or specify its location via the webdriver.chrome.driver
system property. Finally, all you need to do is create a new
ChromeDriver instance:
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
Therefore, download the version of chromedriver you need, unzip it somewhere on your PATH (or specify the path to it via a system property), then run the driver.
We have installed Successfully
sudo apt-get install unzip
wget -N http://chromedriver.storage.googleapis.com/2.10/chromedriver_linux64.zip -P ~/Downloads
unzip ~/Downloads/chromedriver_linux64.zip -d ~/Downloads
chmod +x ~/Downloads/chromedriver
sudo mv -f ~/Downloads/chromedriver /usr/local/share/chromedriver
Change the directory to /usr/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver
sudo ln -s /usr/local/share/chromedriver /usr/bin/chromedriver
Now run the script and add the following in the environment file.
Capybara.register_driver :chrome do |app| client = Selenium::WebDriver::Remote::Http::Default.new Capybara::Selenium::Driver.new(app, :browser => :chrome, :http_client => client) end
Capybara.javascript_driver = :chrome
Note : Change the chrome driver version according to your operating system type like 32 bit or 64 bit.
Here is a complete script for Linux 18.04 to install Google Chrome and the chrome driver. It should automatically adjust to collect the correct chrome driver for the browser.
#!/usr/bin/env bash
# install the latest version of Chrome and the Chrome Driver
apt-get update && apt-get install -y libnss3-dev
version=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
wget -N http://chromedriver.storage.googleapis.com/${version}/chromedriver_linux64.zip
unzip chromedriver_linux64.zip -d /usr/local/bin
chmod +x /usr/local/bin/chromedriver
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install
For me worked with these commands:
Unziped the file -> unzip -q chromedriver_linux64.zip
Force the copy to the directory 'usr/bin' -> sudo mv -f chromedriver /usr/bin
The selenium code was something like that.
System.setProperty("webdriver.chrome.driver","/usr/bin/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("https://mvnrepository.com");
driver.close();
You can see small example from this example
For linux, i downlaod chrome driver and keep as system path variable(or put in exist path folder). And from code i use following ways (add property and initiate with path of chrome driver)
System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
ChromeDriverService service = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("/usr/local/bin/chromedriver"))
.usingAnyFreePort()
.build();
try {
service.start();
} catch (IOException e) {
e.printStackTrace();
}
return new RemoteWebDriver(service.getUrl(), DesiredCapabilities.chrome());