为什么phantomjs不使用splinter python?

时间:2016-02-10 06:13:18

标签: python splinter

我想通过phantom js浏览器登录LinkedIn。我正在使用splinter。在Chrome浏览器中运行时,sp​​linter代码正常工作。但如果我将浏览器更改为幻像js,它会向我显示一些错误,请告诉我如何解决这个问题。 没有幻影js浏览器: 来自splinter import Browser

with Browser() as browser:
    # Visit URL
    URL = "https://www.linkedin.com/"
    browser.visit(URL)
    browser.fill('session_key', 'abc123@gmail.com')
    print("your email id entered correctly") 

It works perfectly
with phantomjs browser:
from splinter import Browser
with Browser('phantomjs') as browser:
    # Visit URL
    URL = "https://www.linkedin.com/"
    browser.visit(URL)
    browser.fill('session_key', 'abc123@gmail.com')
    print("your email id entered correctly")

错误:

Traceback (most recent call last):
  File "sampleFile.py", line 7, in <module>
    browser.fill('session_key', 'abc123@gmail.com')
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/__init__.py", line 413, in fill
    field = self.find_by_name(name).first
  File "/usr/local/lib/python2.7/dist-packages/splinter/element_list.py", line 53, in first
    return self[0]
  File "/usr/local/lib/python2.7/dist-packages/splinter/element_list.py", line 44, in __getitem__
    self.find_by, self.query))
splinter.exceptions.ElementDoesNotExist: no elements could be found with name "session_key"

0 个答案:

没有答案