httplib.BadStatusLine: '' on Linux but not Mac
EDIT 3
Add the following:
except httplib.BadStatusLine: pass
EDIT 2
Python WebDriver and phantomJs have a problem with keep_alive. This could be your problem. So add keep_alive=False as follows:
driver = webdriver.PhantomJS(desired_capabilities=dcap,keep_alive=False)
end edit
Add the following
import httplibimport socketfrom selenium.webdriver.remote.command import Commanddef get_status(driver): try: driver.execute(Command.STATUS) return "Alive" except (socket.error, httplib.CannotSendRequest): return "Dead"
Call get_status(driver) just before the save_screenshot statement and print the result. This will tell us if the driver has prematurely shutdown.
EDIT
Add the following after driver = webdriver.PhantomJS(desired_capabilities=dcap)
driver.implicitly_wait(10) #wait 10 seconds when doing a find_element before carrying on