I having trouble installing PhantomJS to my project
Following the suggestions from the similar question from so I defined the $PATH
variable with executable path
This error message...
No such file or directory: 'phantomjs': 'phantomjs'
...implies that the program was unable to locate the phantomjs binary.
As you are on MAC OS X you need to download phantomjs-2.1.1-macosx.zip from Download PhantomJS page and extract (unzip) the content within your system. Next you can mention the absolute path of phantomjs binary passing the argument executable_path
as follows:
MAC OS X example:
from selenium import webdriver
driver = webdriver.PhantomJS(executable_path='/path/to/phantomjs-2.1.1-xxx/bin/phantomjs')
driver.get('https://www.google.com/')
print(driver.title)
driver.quit()
Windows OS example:
from selenium import webdriver
driver = webdriver.PhantomJS(executable_path=r'C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe')
driver.get('https://www.google.com/')
print(driver.title)
driver.quit()
You need to give the path:
browser = webdriver.PhantomJS(executable_path='Complete path/to/phantomjs')
To find it use export PATH=${PATH:+$PATH:}
in the command line as @Anderson commented.