I am trying to run a python script in which I am opening a webpage and clicking on some element. But the script is running very slow and giving random exceptions . 
Mostly it halts at line
driver = webdriver.Firefox()
Message -

selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile ?Dir: /tmp/tmp4liaEq Firefox output: Xlib:  extension "RANDR" missing on display ":1733".\n1403086712970\taddons.xpi\tDEBUG\tstartup\n1403086713204\taddons.xpi\tDEBUG\tcheckForChanges\n1403086713568\taddons.xpi\tDEBUG\tNo changes found\n'

Sometimes - 
driver.find_element_by_xpath("//a[@id='some_id']")
Returning error that the element is not visible so can't be clicked.
The same script runs smoothly on my system that has 4GB RAM.
(EC2 system specs ~ 600mb memory)
I tried looking into the system and "top" command returned -
604332k total,   577412k used,    26920k free,     6616k buffers
I have installed firefox and also xvfb since i am running the firefox headlessly
I was facing the same problem. 
Running the scripts as root solved the problem.
Also making an user running the test a sudoer worked.
Unable to run python selenium webdriver scripts over Amazon EC2