phantomJS: "'Service' object has no attribute '_log'"

341 views
Skip to first unread message

Peter Nguyen

unread,
Jan 3, 2015, 1:38:27 PM1/3/15
to seleniu...@googlegroups.com
Hi,

I'm using selenium for web testing with PhantomJS, this simple code runs super fine on local machine (ubuntu 14.4) or in python console on server (VPS ubuntu 14.4).
Selenium 2.44, phantom 1.98, nginx 1.4.6, gunicorn 19.11. However, when I try to call it from a flask application, it throws these error:

Code:

from flask import Flask, request
from selenium import webdriver

app = Flask(__name__)
app.debug = True

@app.route("/test")
def test():
    url = "http://www.google.com"
    driver = webdriver.PhantomJS('./phantomjs')
    driver.get(url)
    result = driver.page_source
    driver.close()
    return result

if __name__ == "__main__":
  app.run() 


the server throws an AtrributeError Exception:
Traceback (most recent call last):
 
File "/usr/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 126, in handle_request
    respiter
= self.wsgi(environ, resp.start_response)
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__
   
return self.wsgi_app(environ, start_response)
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
    response
= self.make_response(self.handle_exception(e))
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise
(exc_type, exc_value, tb)
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response
= self.full_dispatch_request()
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv
= self.handle_user_exception(e)
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise
(exc_type, exc_value, tb)
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv
= self.dispatch_request()
 
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
   
return self.view_functions[rule.endpoint](**req.view_args)
 
File "/home/www/flask_project/app.py", line 10, in index
    br
= webdriver.PhantomJS('./phantomjs')
 
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/webdriver.py", line 49, in __init__
    service_args
=service_args, log_path=service_log_path)
 
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/phantomjs/service.py", line 53, in __init__
   
self._log = open(log_path, 'w')
IOError: [Errno 13] Permission denied: 'ghostdriver.log'
Exception AttributeError: "'Service' object has no attribute '_log'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7fcc6eb18710>> ignored


I tried to run it with both root and other admin accounts, the probelm still persists. Since I couldn't google this error so I post this here and hope someone can help.

Thank you
Reply all
Reply to author
Forward
0 new messages