Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ';chromedriver';可执行文件需要位于路径中,但它';已经有了_Javascript_Python_Python 3.x - Fatal编程技术网

Javascript ';chromedriver';可执行文件需要位于路径中,但它';已经有了

Javascript ';chromedriver';可执行文件需要位于路径中,但它';已经有了,javascript,python,python-3.x,Javascript,Python,Python 3.x,我想用Python向发送一条消息 也就是说,使用python执行以下操作: 这就是为什么我尝试使用Selenium编写以下脚本: api_location = 'http://iphoneapp.spareroom.co.uk' api_search_endpoint = 'flatshares' api_details_endpoint = 'flatshares' location = 'http://www.spareroom.co.uk' details_endpoint = 'fl

我想用Python向发送一条消息

也就是说,使用python执行以下操作:

这就是为什么我尝试使用Selenium编写以下脚本:

api_location = 'http://iphoneapp.spareroom.co.uk'
api_search_endpoint = 'flatshares'
api_details_endpoint = 'flatshares'

location = 'http://www.spareroom.co.uk'
details_endpoint = 'flatshare/flatshare_detail.pl?flatshare_id='
def contact_room(self, room_id):
    url = '{location}/{endpoint}/{id}?format=json'.format(location=self.api_location, endpoint=self.api_details_endpoint, id=room_id)
    from selenium import webdriver

    driver = webdriver.Chrome()
    # Go to your page url
    driver.get(url)
    # Get button you are going to click by its id ( also you could use find_element_by_css_selector to get element by css selector)
    button_element = driver.find_element_by_id('button id')
    button_element.click()
但它的回报是:

C:\Users\antoi\Documents\Programming\projects\roomfinder>python test_message.py
Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Python36\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Python36\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test_message.py", line 21, in <module>
    contact_room(13829371)
  File "test_message.py", line 14, in contact_room
    driver = webdriver.Chrome()  # Optional argument, if not specified will search path.
  File "C:\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
    self.service.start()
  File "C:\Python36\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
C:\Users\antoi\Documents\Programming\projects\roomfinder>python test\u message.py
回溯(最近一次呼叫最后一次):
文件“C:\Python36\lib\site packages\selenium\webdriver\common\service.py”,第76行,在开始处
标准偏差=管道)
文件“C:\Python36\lib\subprocess.py”,第709行,在\uuu init中__
恢复信号,启动新会话)
文件“C:\Python36\lib\subprocess.py”,第997行,在执行子进程中
startupinfo)
FileNotFoundError:[WinError 2]系统找不到指定的文件
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“test_message.py”,第21行,在
联络室(13829371)
文件“test_message.py”,第14行,在联络室
driver=webdriver.Chrome()#可选参数,如果未指定,将搜索路径。
文件“C:\Python36\lib\site packages\selenium\webdriver\chrome\webdriver.py”,第73行,在\uuu init中__
self.service.start()
文件“C:\Python36\lib\site packages\selenium\webdriver\common\service.py”,第83行,在开始处
os.path.basename(self.path)、self.start\u错误消息)
selenium.common.exceptions.WebDriverException:消息:“chromedriver”可执行文件需要位于路径中。请看https://sites.google.com/a/chromium.org/chromedriver/home
虽然我已经在路径中添加了它:


我是javascript学习者。如果您有技巧和时间来演示如何用Javascript回答问题,我很乐意学习:)

chromedriver需要位于python脚本的路径中,或者您需要将其添加到驱动程序中:

driver_path = 'Path\to\your\Driver'
driver = webdriver.Chrome(executable_path = driver_path)

为什么要使用
webdriver.Firefox()
如果您谈到
Chrome

chromedriver需要位于python脚本的路径中,或者您需要将其添加到驱动程序中:

driver_path = 'Path\to\your\Driver'
driver = webdriver.Chrome(executable_path = driver_path)

如果你说的是
Chrome
,那你为什么要使用
webdriver.Firefox()

很抱歉,确实是
webdriver.Chrome()
。是否应该是
driver\u path=C:\Program Files
,例如,如果我的驱动程序在那里?但是我得到了selenium.common.exceptions.WebDriverException:消息:“Program Files”可执行文件可能有错误的权限。请看https://sites.google.com/a/chromium.org/chromedriver/home不应该是
driver\u path=C:\Program Files\chromedriver
driver\u path=C:\Program Files\chromedriver.exe
。很抱歉,确实是
webdriver.Chrome()。是否应该是
driver\u path=C:\Program Files
,例如,如果我的驱动程序在那里?但是我得到了selenium.common.exceptions.WebDriverException:消息:“Program Files”可执行文件可能有错误的权限。请看https://sites.google.com/a/chromium.org/chromedriver/home
No应该是
driver\u path=C:\Program Files\chromedriver
driver\u path=C:\Program Files\chromedriver.exe