from selenium import webdriver browser = webdriver.PhantomJS() browser.implicitly_wait(3) browser.get("https://google.com") r = browser.execute_script("return 100 + 50") print(r)
[vagrant@localhost python]$ python3 app.py
/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
warnings.warn(‘Selenium support for PhantomJS has been deprecated, please use headless ‘
150
r = browser.execute_script("var date = new Date(), console.log(date)")