返回顶部

我最近安装了 PhantomJS,第一次运行时遇到了这个错误: from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.PhantomJS() driver.get("http://www.google.com") driver.find_element_by_id('some_element').send_keys('something' + Keys.RETURN) 此代码适用于 Firefox webdriver,但不适用于 PhantomJS。我收到以下错误: Traceback (most recent call last): File "", line 20, in driver.find_element_by_id('lst-ib').send_keys('something' + Keys.RETURN) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 266, in find_element_by_id return self.find_element(by=By.ID, value=id_) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 744, in find_element {'using': by, 'value': value})['value'] File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.5/dist-packages/se

1

0/300

评论 1

fish

原因是我apt-get install Phantomjs以前安装过,但是好像是安装的不是全功能的Phantomjs版本apt-get。因此,从 Phantomjs 网站手动下载并将包含方向添加到PATH环境变量中。

2022-01-11 15:26:59

- 没有更多了 -