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/myscript.py"
Visiting github
Performing search
Traceback (most recent call last):
File "/mnt/myscript.py", line 8, in <module>
searchbox.send_keys('docker-in-practice\n')
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", 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/webelement.py", line 457, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", 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
Stacktrace:
at fxdriver.preconditions.visible (file:///tmp/tmpbGp3_A/extensions/fxdriver@googlecode.com/components/command-processor.js:10092)
at DelayedCommand.prototype.checkPreconditions_ (file:///tmp/tmpbGp3_A/extensions/fxdriver@googlecode.com/components/command-processor.js:12644)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpbGp3_A/extensions/fxdriver@googlecode.com/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpbGp3_A/extensions/fxdriver@googlecode.com/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///tmp/tmpbGp3_A/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)
It works when I do this:
#!/bin/bash
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/myscript.py
|