The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

mancocapac (15) [Avatar] Offline
It works fine until I get to the xvfb part.
When I run the script I get: "Element is not currently visible" for the "searchselector", same selector worked in the X11 part of TECH58. I thought it was a page/element load issue so I put in WebDriverWait until presence_of_element_located, it seems the element is present but not visible. I also tried visibility_of_element_located, but it does not pass this. I upped the time out to 100 secs.

The same script runs when I use the X11 style command line (see below)

docker run --rm -v $(pwd):/mnt selenium sh -c "xvfb-run -s '-screen 0 1024x768x24 -extension RANDR'\
> python /mnt/"
Visiting github
Performing search
Traceback (most recent call last):
  File "/mnt/", line 8, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 322, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT, {'value': keys_to_typing(value)})
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 457, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 233, in execute
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
    at fxdriver.preconditions.visible (file:///tmp/tmpbGp3_A/extensions/
    at DelayedCommand.prototype.checkPreconditions_ (file:///tmp/tmpbGp3_A/extensions/
    at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpbGp3_A/extensions/
    at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpbGp3_A/extensions/
    at DelayedCommand.prototype.execute/< (file:///tmp/tmpbGp3_A/extensions/

It works when I do this:
docker run -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  --hostname=$HOSTNAME \
  -v $HOME/.Xauthority:/root/.Xauthority \
  -v $(pwd):/mnt \
  -it selenium bash

<on-the-container>$ python /mnt/

mancocapac (15) [Avatar] Offline
has anybody run this example? I'm wondering if there is something I am doing incorrectly, as I am new to docker and I don't know python.
like I said above, the same script runs successfully with X11, but gets hung up with xvfb
- thanks
mancocapac (15) [Avatar] Offline
see: An element can't be clicked when the browser controlled by Selenium is displayed through xvfb #5828

add the following line

from selenium import webdriver
b = webdriver.Firefox()
b.set_window_size(1024, 768)    ### Add this line, Must match  command line for xvfb screen

xvfb-run -s '-screen 0 1024x768x24 -extension RANDR'

please update code sample
aidanhs (25) [Avatar] Offline
Hi mancocapac, thanks for the detailed investigation and the fix

Unfortunately, I'm unable to check this right now as a recent firefox update in the Ubuntu repositories has broken selenium entirely (

For when the fixed firefox is released, can you confirm you were using an Ubuntu 14.04 image? I tested this technique on multiple computers, so I'm a little surprise that it's broken! Such is the price of progress I suppose.