def execute(script, args):
    driver.execute('executePhantomScript', {'script': script, 'args': args})
driver = webdriver.PhantomJS('phantomjs')
driver.command_executor._commands['executePhantomScript'
    ] = 'POST', '/session/$sessionId/phantom/execute'
Python + Selenium + PhantomJS визуализировать в PDF