FreeBSD Selenium PhantomJS - Não é possível conectar-se ao serviço

0

Estou preso para rodar o PhantomJS com selênio. Então eu preparei uma FreeBSD Jail e instalei phantomjs via ports.

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

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

Meu script parece com isso:

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()

Mas sempre recebo esses erros e não consigo encontrar uma solução

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
    
por raxer 21.01.2016 / 22:19

1 resposta

0

Tente especificar "service_log_path" explicitamente:

driver = webdriver.PhantomJS(executable_path='/usr/local/bin/phantomjs', service_log_path='/tmp/ghostdriver.log')
    
por 08.07.2016 / 01:27