1

i am stuck to run PhantomJS with selenium. So i have prepared a FreeBSD Jail and installed phantomjs via ports.

whereis phantomjs
> phantomjs: /usr/local/bin/phantomjs /usr/ports/lang/phantomjs

/usr/local/bin/phantomjs -v
> 2.0.0

My script looks likes this:

from selenium import webdriver

PHANTOM_PATH = '/usr/local/bin/phantomjs'

driver = webdriver.PhantomJS(executable_path=PHANTOM_PATH)
driver.set_window_size(1024, 768)
driver.get('https://google.com/')
driver.save_screenshot('screen.png')
driver.quit()

But i always get these errors and can't find a solution

File "driver.py", line 5, in <module>
driver = webdriver.PhantomJS(PHANTOM_PATH)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 51, in __init__
self.service.start()
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 88, in start
raise WebDriverException("Can not connect to the Service %s" % self.path)
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service /usr/local/bin/phantomjs

Exception AttributeError: AttributeError("'NoneType' object has no attribute 'close'",) in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x8007981d0>> ignored
raxer
  • 41
  • 1
  • 4

1 Answers1

0

Try to specify "service_log_path" explicitly:

driver = webdriver.PhantomJS(executable_path='/usr/local/bin/phantomjs', service_log_path='/tmp/ghostdriver.log')
ARA1307
  • 131
  • 2