51Testing软件测试论坛

标题: 求助大神,这个python+webdriver+phantomjs的代码,为什么会报错cookiejar不存在 [打印本页]

作者: kylintwo    时间: 2016-5-23 20:42
标题: 求助大神,这个python+webdriver+phantomjs的代码,为什么会报错cookiejar不存在
from selenium import webdrvier
driver=webdriver.PhantomJS(ur"/home/kylinu/下载/phantomjs-1.9.6-linux-x86_64/bin/phantomjs")



执行如下报错信息:
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7f21279ff090>> ignored
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7f21279ff110>> ignored
Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.phantomjs.service.Service object at 0x7f212a95c590>> ignored
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 56, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 91, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 173, in start_session
    'desiredCapabilities': desired_capabilities,
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute
    self.error_handler.check_response(response)
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 165, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Error - Cannot find module 'cookiejar'
[qq]975168367[/qq]请大神指教


作者: 掉渣饼    时间: 2016-5-24 09:56
driver=webdriver.PhantomJS(ur"/home/kylinu/下载/phantomjs-1.9.6-linux-x86_64/bin/phantomjs")
把这个换成
driver = webdriver.PhantomJS(executable_path=r'/home/kylinu/下载/phantomjs-1.9.6-linux-x86_64/bin/phantomjs')  
试试看行不行
作者: kylintwo    时间: 2016-5-24 11:04
掉渣饼 发表于 2016-5-24 09:56
driver=webdriver.PhantomJS(ur"/home/kylinu/下载/phantomjs-1.9.6-linux-x86_64/bin/phantomjs")
把这个 ...

Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
>>> driver = webdriver.PhantomJS(executable_path=r'/home/kylinu/下载/phantomjs-1.9.6-linux-x86_64/bin/phantomjs')  
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 56, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 91, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 173, in start_session
    'desiredCapabilities': desired_capabilities,
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute
    self.error_handler.check_response(response)
  File "/home/kylinu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 165, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: Error - Cannot find module 'cookiejar'

作者: kylintwo    时间: 2016-5-24 11:05
掉渣饼 发表于 2016-5-24 09:56
driver=webdriver.PhantomJS(ur"/home/kylinu/下载/phantomjs-1.9.6-linux-x86_64/bin/phantomjs")
把这个 ...

一样的呢。。。。也报错cookiejar的问题
作者: kylintwo    时间: 2016-5-24 11:06
掉渣饼 发表于 2016-5-24 09:56
driver=webdriver.PhantomJS(ur"/home/kylinu/下载/phantomjs-1.9.6-linux-x86_64/bin/phantomjs")
把这个 ...

一样的呢。也报错cookiejar的问题




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2