I am trying to get Selenium to do some automated browsing on a Linux application server. I am stuck at the point where my 'perl recording' from Selenium sends a request to start the browser, and the standalone selenium server throws an error - 'Timed out waiting for profile to be created!'.
I understand from browsing this error, that I could resolve this by creating a profile for the firefox browser I installed on the linux server. However, when I try to create a profile, I now get the error -
Error: no display specified
When I look this up, I find SO posts that suggest I could resolve this by installing xvfb first on the server and then setting the DISPLAY variable before starting the selenium server. However, I am not a root user, and wanted to check if xvfb can be installed locally on a user's home directory.
First need to install X window system frame buffer x server:
yum install xorg-x11-server-Xvfb.x86_64
make sure you have firefox installed, then start the x server on some display port like 99
Xvfb :99 -ac -screen 0 1280x1024x24 &
Set the DISPLAY environment to 99 by export DISPLAY=:99 in your code or maybe in bash profile.
try Xdummy to launch X server in virtual frame buffer, it does not need root.
http://www.karlrunge.com/x11vnc/Xdummy
Related
I am trying to run python script
from selenium import webdriver
from pyvirtualdisplay import Display
Display(visible=1, size=(800, 600)).start()
driver = webdriver.Chrome(options=option)
driver.get("https://google.com")
but I am getting error "Xephyr cannot open host display. Is DISPLAY set?
It's minimal ubuntu 18.04 installation with x11 installed
also chromium-browser works only when I type startx chromium-browser, otherwise it's drop Trace/breakpoint trap (core dumped)
#update
when I run sudo xinit and run my script manually it works but in window, not fullscreen, are there another way to run it?
#update
I was trying to set options in python script to run fullscreen like "--start-fullscreen" and "--start-maximized" but it cover half of screen like here: https://unix.stackexchange.com/questions/273989/how-can-i-make-chromium-start-full-screen-under-x
also I was trying to edit Preferences for chromium like in this thread in /home//.config/chromium/Default/Preferences, but its not working, I saw that every run of my python script chromium generate new Preferences in /tmp/.org.chromium.Chromium./Default/Preferences this browser setting are different than these in /home//.config/(...)/Preferences
ofc I have delete Display option from python script
Any help?
I have a script in which I build a mlagents_envs.environments.UnityEnvironment that successfully launches and works when I run the script from terminal sessions started on my ubuntu machine (that has a GUI). And if I ssh into the machine, I can run these scripts from tmux sessions that were originally created locally on my machine. If, however, I try to run the script from a terminal session created through the remote ssh connection, the script hangs when trying to create the UnityEnvironment. It just says:
Found path: <path_to_unity_executable>
and eventually times out.
I've tried to run the script with a virtual display and it still doesn't work. Specifically, I've tried:
$ xvfb-run --auto-servernum --server-args='-screen 1 640x480x24:64' python3 python_script.py -batchmode
$ xvfb-run --auto-servernum --server-args='-screen 1 640x480x24:64' python3 python_script.py
And I've tried the instructions found here: https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Training-on-Amazon-Web-Service.md
Has anyone encountered this issue? Do you have any suggestions?
The solution ended up being fairly simple. I just needed to specify the right DEVICE before running the script.
$ DEVICE=:1 python3 python_script.py
If anyone else runs into this, you might also need to enable X11 forwarding in both the ssh settings on the server and the client. I'm not 100% sure.
I want to run a pyvirtualdisplay on my Mac.
After installing all dependencies I installed X11 because
i needed Xvfb to run and changed some permission for some folder called ~/.Xauthority to 777.
Still, if I ran
display = pyvirtualdisplay.Display(visible=0, size=(320, 240)).start()
XStartTimeoutError: Failed to start X on display ":1013" (xdpyinfo check failed).
What I also tryed was to change
X11Forwarding in my /etc/ssh/sshd_config file to yes.
Did not work out.
How can I resolve the issue?
Constructive help appreciated.
I got this same error while trying to run Selenium using PyVirtualDisplay on my Raspberry Pi. I was not running Xephyr.
In a separate terminal window I ran
export DISPLAY=:0 XAUTHORITY=/etc/X11/host-Xauthority
and then
Xephyr :1 -fullscreen
Then re ran my python script and it worked.
If that doesn't work for you, here is where the actual error is occurring in the PyVirtualDisplay package: https://github.com/ponty/PyVirtualDisplay/blob/d229fcf892fdda17887684b977365d1fa90255eb/pyvirtualdisplay/abstractdisplay.py#L149
As you can see, you might need to install xdpyinfo in some form on your Mac.
I am trying to run Protractor e2e tests inside a Vagrant VM using headless Chrome.
I managed to get it working by using Xvfb but when I run a test to fill a form I get an error: unknown error: an X display is required for keycode conversions, consider using Xvfb
All tests run fine but as soon as I use getKeys() (e.g. element(by.model('user.email')).sendKeys('admin'); ) I get this error, even though I am already using Xvfb.
I'm running:
AngularJS sample app generated with the Yeoman angular-fullstack generator
Nodejs version 0.10.30, installed with nvm
Vagrant 1.6.3
VirtualBox 4.3.14
Host OS Ubuntu 14.04 32 bits
Guest OS Ubuntu 14.04 32 bits
chrome 37.0.2062.94
chromedriver 2.10.267517
I use the following shell script to start Selenium and Xvfb:
#!/bin/sh
webdriver-manager start &
Xvfb :1 -ac -screen 0 1280x1024x8 &
export DISPLAY=:1
I also added "export DISPLAY=:1" to /opt/google/chrome/google-chrome.
Again, tests without sendKeys() run fine.
What I have done so far:
I'm running 32 bits Ubuntu so I downloaded chromedriver 2.10 32 bits but that didn't help
I ran chromedriver with --verbose and checked the logs but that only shows the same error
I fiddled with the Xvfb screen dimension settings, didn't help either
I checked some source code here: https://github.com/bayandin/chromedriver/blob/master/keycode_text_conversion_x.cc and found the error message on line 196.
It's triggered when the command gfx::GetXDisplay() (line 193) doesn't get a display object. I suspect that it might be just the DISPLAY variable I export in /opt/google/chrome/google-chrome but I'm not sure and have no idea how to fix it.
I would like to know how I can get sendfkeys() working with headless Chrome inside a Vagrant VM.
Any help is greatly appreciated.
Ensure seleniumAddress: 'http://localhost:4444/wd/hub' matches your selenium server and avoid setting chromeOnly since that will effectively avoid using the headless selenium server.
Also, Xvfb needs to run before webdriver-manager and you're missing xvfb-run given you seem to need it to do the X authority dance for you:
#!/bin/sh
export DISPLAY=:1
Xvfb $DISPLAY -ac -screen 0 1280x1024x8 &
sleep 1
xvfb-run webdriver-manager start &
In case you're interested I've setup a headless docker based solution with optional VNC access plus video recording: https://github.com/elgalu/docker-selenium
I have a BeagleBone - no LCD/display. In the console when I try and use startx, it says /dev/fb0 doesn't exist. The xorg.conf file is using the fbdev driver. Apparently, if an LCD is detected, everything works.
How can I setup a virtual display so I can vnc to it?
Thought I better answer this for reference. Oh, I also got the 'Tumbleweed' badge... Great...
If no LCD/DVI cape is attached, then the boot doesn't load a frame buffer (/dev/fb0). As such, no X11 server starts up. x11vnc requires a real X11 server to be running for it to work. There is also the program xvnc which can create a virtual X11/frame buffer on your behalf, but I couldn't see it in the Angstrom packages.
So, I installed Xvfb - and created a virtual frame buffer. Install the package
xserver-xorg-xvfb
When starting, keep in mind (for the newbies like me coming from Windows), it is case-sensitive. To create a virtual X11 server;
Xvfb :1 -screen 0 1024x768x16 &
When you do this, you will probably get these errors;
(EE) AIGLX error: dlopen of /usr/X11/lib/dri/swrast_dri.so failed (dlopen(/usr/X11/lib/dri/swrast_dri.so, 5): image not found)
(EE) GLX: could not load software renderer
So, load the package;
mesa-dri-driver-swrast
OK, error gone. Now we can export our display (an environment variable so Firefox, or whatever X11 client you run, can attach to the display).
export DISPLAY=:1
Load up Firefox (something to see)
firefox &
And now we try and start the x11vnc;
x11vnc -display :1 -bg -nopw -xkb
At this point, with this distro, you'll see an error about XTEST not being found/not available when it was built. Here describes the issue.
I made sure that I had all the proper libraries installed, so I figured it must have been a bad build on Angstrom. So, now to build it myself. I ensured all required libraries were available; these are the ones ending with '-dev'; by default they all appeared to be available. I followed the instructions here.
Except the copy line didn't work too good for me, so do what you need to do to copy it to the /usr/bin folder.
Now it starts, and there are no errors about XTEST, and the input works!