dcap = dict(DesiredCapabilities.PHANTOMJS)
dcap['phantomjs.page.settings.userAgent'] = user_agent
browser = webdriver.PhantomJS(desired_capabilities=dcap)
Python Selenium with Phantomjs - Click Failed: ReferenceError: Cant't find variable