SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
347 stars 195 forks source link

An element can't be clicked when the browser controlled by Selenium is displayed through xvfb #5828

Open lukeis opened 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 5828

An area of the HTML page can't be clicked in a headless environment whereas it can in
a "headful" environment.

As you can see in the Xvfb screenshot (attached), the area inside the red rectangle
can't be clicked.

This bug depends on the system environment.
It occurs when the browser driven by Selenium server standalone is displayed through
`xvfb`.
The same click will work properly on the same system when the browser driven by Selenium
server standalone is displayed through an X11 (forwarded through SSH).

The bug occurs since version 2.33 of Selenium standalone server. It does not with versions
2.31 and 2.32.
The bug occurs with Firefox version 21. We don't know if it affects other versions
of Firefox.
The bug does not occur with Google Chrome.

== What is the specific environment?

=== Download the virtual machine

Here you can find a ready-to-use virtual machine for VirtualBox, so you can run all
tests you want in the environment that triggers the described bug.

[https://www.dropbox.com/s/uodcjnbembaqjuy/ubuntu_headless.ova]

The user is `test`, its password is `test`.

SSH is redirected on `localhost:2200`
HTTP is redirected on `localhost:8000`

=== Or install one yourself

If you can't get the virtual machine, the following steps allow to reproduce the environment:

* Install an Ubuntu server 12.04 x64 on a virtual machine.
* Install the following packages: `xvfb` `openjdk-7-jre` `x11-apps` `firefox`.
* Install Selenium server standalone version 2.33.

If your host machine is OS X, install xquartz to get the X11 forwarding working.

Follow these instructions to assert the environment setup:

The environment is really headless if:

* SSH on the virtual machine: `ssh <user>@<ubuntu-server>`
* Run `xclock`, it should fail with this kind of error: "Error: Can't open display:"

The X11 forwarding works if:

* SSH on the virtual machine with the X11 forwarding: `SSH -X user@ubuntu-server`
* Run `xclock`, it should display a clock in your host OS.

The environment can run graphical programs headlessly if:

* SSH on the virtual machine: `ssh <user>@<ubuntu-server>`
* Run `xvfb` in background: `xvfb :99 &`
* Set the current display to xvfb: `export DISPLAY=:99`
* Run `xclock`, it should not print anything, but it should not fail. Press Ctrl+C
to stop xclock after a few seconds.

== What steps will reproduce the problem?

I can reproduce the bug. I tried to extract a minimal test case from our corporate
source code but unfortunately I didn't succeed due to the size of dependencies.

I hope that running the selenium standalone test suite within the provided environment
could help to identify the problem and correct this bug.

== What is the expected output?

Through X11 forwarding:

When you click on one of the 12th line buttons (see attached screenshot), it works
properly.

Environment:

* SSH with the X11 forwarding: `ssh -X user@ubuntu-server`.
* Setup the good display: `export DISPLAY=localhost:10.0`.
* Start Selenium server from this shell session: `java -jar selenium-server-standalone.jar
> selenium.log`.

Now, Selenium server is displayed through the X11 forwarding. So when Selenium server
opens a browser you see it in your host OS.

Here is the server log:

{{{
16:39:02.957 INFO - Executing: [find element: By.selector: #sst table tbody tr:nth-child(10)
td:nth-child(2) a[data-for$="no"]] at URL: /session/0bd09de8-cc02-471e-85e6-fc693a756714/element)
16:39:02.966 INFO - Done: /session/0bd09de8-cc02-471e-85e6-fc693a756714/element
16:39:02.980 INFO - Executing: [click: 32 org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement@f98a3ea9]
at URL: /session/0bd09de8-cc02-471e-85e6-fc693a756714/element/32/click)
16:39:03.153 INFO - Done: /session/0bd09de8-cc02-471e-85e6-fc693a756714/element/32/click
}}}

== What do you see instead?

Through xvfb:

You can't click on one of the 12th line buttons (see attached screenshot).

Environment:

* SSH: `ssh <user>@<ubuntu-server>`
* Run xvfb in the background: `xvfb :99` (default screen size is 1280x1024)
* Setup the good display: `export DISPLAY=:99`
* Start Selenium server from this shell session: `java -jar selenium-server-standalone.jar
> selenium.log`

Now, your Selenium server is displayed through xvfb. So when Selenium server opens
a browser you do not see anything.

You will find the relevant server log excerpt attached.

== Please provide any additional information below.

The screen size affects the bug. With different screen sizes, the size of the non-clickable
area changes. It can get smaller or greater. (Run Xvfb with the -screen option to change
the display)

Reported by thomas.debona on 2013-06-25 07:48:41


lukeis commented 8 years ago
I can confirm this issue, the same thing is hapenning to me:
 * Python-selenium script works well with X11
 * The same script with xvfb doesn't work
 * If I switch to Chrome as my browser (with xvfb) it works.

Any ideas on what could be causing this issue?

Reported by andres.riancho on 2013-08-08 12:02:23

lukeis commented 8 years ago
More info for the bug report, when the test fails in xvfb I take a screenshot and instead
of the button I want to click I see the attached image, which is NOT something I have
in my web application.

Reported by andres.riancho on 2013-08-08 12:20:02


lukeis commented 8 years ago
Based on the "Xvfb screenshot.png" screenshot of the first bug report, it seems that
Thomas is using Bootstrap for the web application, which I'm also doing. Maybe it has
something (very strange) to do with that?

Reported by andres.riancho on 2013-08-08 12:42:08

lukeis commented 8 years ago
In my case the icon was a bootstrap feature which "compresses" the top navbar when the
screen has not enough space, thus hiding the button I wanted to press from user's view.
I solved it by making the Xvfb screen bigger.

Reported by andres.riancho on 2013-08-08 19:48:30

lukeis commented 8 years ago

Reported by barancev on 2013-08-08 23:11:22

lukeis commented 8 years ago
Also experiencing issues with focus for firefox in an xvfb session. Other browsers do
not seem to suffer this problem.

Reported by lloydwatkin on 2014-06-23 08:18:45

lukeis commented 8 years ago
I tried to maximize the windows at beginning and didn't work, I realized screenshots
from both environments were different size (yes, the resolution is different). So you
might also need to start the display using a bigger resolution. To me Xvfb(width=1440,
height=755) was perfect

Reported by cherny@bolivarcoders.com on 2015-04-18 16:01:46

lukeis commented 8 years ago
This is what I had to do to get around the issue. 

driver.manage().window().setSize(new Dimension(1920,1080));

This in addition to running xvfb at a 1920x1080 resolution. Had to do both for it to
work. 

Reported by konradt95 on 2015-05-12 18:36:48

lukeis commented 8 years ago
Found this as well.  A certain drop-down was failing to click through, only when run
via Xvfb.  Setting the xvfb resolution to 1920x1080 solved it.

Changed my selenium standalone invocation to this:

xvfb-run -s "-screen 0, 1920x1080x24" java -jar ~/selenium/selenium-server-standalone-2.47.1.jar

Reported by andre.dalle on 2015-08-24 20:39:47

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 17:45:54