0

I have the following setup for my selenium tests:

Hub machine in Linux. Couple of virtual machines as nodes, Linux and Windows created using Vagrant scripts.

If I start selenium node in Linux machine using vagrant script (as part of the provisioning), I am not able to run the selenium tests. But if I login to Linux box and run exactly the same script, I can run the tests.

I enabled the log, an what I se ein log is "cannot set DISPLAY". I am quite sure it is something to do with setting DISPLAY variable. But set the display and didn't work.

So, any of you have faced this or can help me?

Content of Vagrant file

# -*- mode: ruby -*-
# vi: set ft=ruby :
NODE_COUNT=Integer(ENV["NODE_COUNT"])

Vagrant.configure("2") do |config|
  (1..NODE_COUNT).each do |i|
    config.vm.define "node#{i}" do |subconfig|
      subconfig.vm.box = "ubuntu_18_04"
      subconfig.vm.network "private_network", type: "dhcp"
      subconfig.vm.boot_timeout = 600
      subconfig.vm.graceful_halt_timeout = 600
      #  config.disksize.size = '50GB'
      subconfig.vm.provision "shell", path: "provision.sh"
      subconfig.vm.provision "shell", path: "startup.sh", run: 'always'
      #subconfig.vm.provision :reload
    end
  end
end

Content of startup.sh

echo "start selenium node"
HOST_IP=`ifconfig | grep 172| cut -d" " -f 10`
java -Dwebdriver.chrome.driver="/home/vagrant/test/node_modules/electron-chromedriver/bin/chromedriver"  -jar "/home/vagrant/test/selenium-server-standalone.jar" -role node -hub http://172.28.128.1:4444/grid/register/ -browser "browserName=chrome,maxinstances=1,platform=LINUX" -host $HOST_IP &
  • This has nothing to do with Selenium, right? I believe this a Linux question. This is also a broad question and without the contents of the Vagrant scripts (and other related things), it's almost imposssible to anyone to answer this. – Aulis Ronkainen Jul 9 at 19:00
  • Yes, it shouldn't have anything related to selenium. My setup should be something very common and I was hoping I am missing something very obvious. So, just checking if there is something ovious – wantro Jul 9 at 20:27
0

Got the answer. Finally it was a mixture of vagrant running process in background and setting DISPLAY as well. I modified scripts as below:

# -*- mode: ruby -*-
# vi: set ft=ruby :
NODE_COUNT=Integer(ENV["NODE_COUNT"])

Vagrant.configure("2") do |config|
  (1..NODE_COUNT).each do |i|
    config.vm.define "node#{i}" do |subconfig|
      subconfig.vm.box = "ubuntu_18_04"
      subconfig.vm.network "private_network", type: "dhcp"
      subconfig.vm.boot_timeout = 600
      subconfig.vm.graceful_halt_timeout = 600
      #  config.disksize.size = '50GB'
      subconfig.vm.provision "shell", path: "provision.sh"
      subconfig.vm.provision "shell", privileged:false, path: "startup.sh", run: 'always'
      subconfig.vm.provision :reload
    end
  end
end

startup.sh contents:

set -x
echo "start selenium node"
HOST_IP=`ifconfig | grep 172| cut -d" " -f 10`
export DISPLAY=:0.0
command="java -Dwebdriver.chrome.driver=/home/vagrant/test/node_modules/electron-chromedriver/bin/chromedriver  -jar /home/vagrant/test/selenium-server-standalone.jar -role node -hub http://172.28.128.1:4444/grid/register/ -browser browserName=chrome,maxinstances=1,platform=LINUX -host $HOST_IP"
screen -md $command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.