Python 无效参数?

Python 无效参数?,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,所以,我尝试在ubuntu上使用selenium和我的新电脑,但我遇到了这个问题,我真的不知道我能做些什么来解决它 代码如下: driver = webdriver.Firefox(executable_path='./geckodriver') # launch firefox driver.get("https://www.tiktok.com/@programm___r?lang=en") # go to the website WebDri

所以,我尝试在ubuntu上使用selenium和我的新电脑,但我遇到了这个问题,我真的不知道我能做些什么来解决它

代码如下:

    driver = webdriver.Firefox(executable_path='./geckodriver') # launch firefox 
    driver.get("https://www.tiktok.com/@programm___r?lang=en") # go to the website 
    WebDriverWait(driver,20).until(EC.element_to_be_clickable((By.CLASS_NAME,"jsx-2482409767.upload-wrapper"))).click() # click on an element 
    files = os.listdir(folder_name) # Get all the file of the folder "folder_name"
        exts = ["mp4","mov"] # just the extension to pick only the file I want 
        for file in files: 
            if file.split(".")[-1] in exts: # Select only the file I want 
               WebDriverWait(driver,20).until(EC.presence_of_element_located((By.CLASS_NAME,class_name))) # wait for an element to appear 
               driver.find_element_by_class_name(class_name).send_keys(folder_name+"\\"+file) # I'm trying to send the file the for just picked 
               # but this is what cause the error
               # I also tried with the absolute way but it didn't work neither
               driver.find_element_by_class_name(class_name).send_keys(absolute_way+"\\"+file)
以下是回溯:

Traceback (most recent call last):
  File "auto_post.py", line 167, in <module>
    ordi_post("./Video/over","Firefox","linux","programmer")
  File "auto_post.py", line 142, in ordi_post
    wait_send("jsx-1828163283.upload-btn-input",r"home\\pierre\\Documents\\python_projet\\Program_r\\Video\\over\\"+file)
  File "auto_post.py", line 122, in wait_send
    driver.find_element_by_class_name(class_name).send_keys(send_file)
  File "/home/pierre/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 477, in send_keys
    self._execute(Command.SEND_KEYS_TO_ELEMENT,
  File "/home/pierre/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/home/pierre/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/pierre/.local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: File not found: home\\pierre\\Documents\\python_projet\\Program_r\\Video\\over\\Treecko.mp4
回溯(最近一次呼叫最后一次):
文件“auto_post.py”,第167行,在
ordi_post(“./视频/over”、“Firefox”、“linux”、“程序员”)
ordi_post中第142行的文件“auto_post.py”
等待发送(“jsx-1828163283.上传btn输入”,r“home\\pierre\\Documents\\python\u projet\\Program\u r\\Video\\over\\\”+文件)
文件“auto_post.py”,第122行,正在等待发送
驱动程序。通过类名称(类名称)查找元素。发送密钥(发送文件)
文件“/home/pierre/.local/lib/python3.8/site packages/selenium/webdriver/remote/webelement.py”,第477行,在send_key中
self.\u execute(Command.SEND\u KEYS\u到\u元素,
文件“/home/pierre/.local/lib/python3.8/site packages/selenium/webdriver/remote/webelement.py”,第633行,在
返回self.\u parent.execute(命令,参数)
文件“/home/pierre/.local/lib/python3.8/site packages/selenium/webdriver/remote/webdriver.py”,执行中第321行
self.error\u handler.check\u响应(响应)
文件“/home/pierre/.local/lib/python3.8/site packages/selenium/webdriver/remote/errorhandler.py”,第242行,在check_响应中
引发异常类(消息、屏幕、堆栈跟踪)
selenium.common.exceptions.InvalidArgumentException:消息:找不到文件:home\\pierre\\Documents\\python\u projet\\Program\u r\\Video\\over\\Treecko.mp4
我尝试将\改为/但也不起作用。
如果有人有想法,我正在听!

堆栈跟踪是自我探索的:

File not found: home\\pierre\\Documents\\python_projet\\Program_r\\Video\\over\\Treecko.mp4
确保此文件和路径存在

使用:


文件的绝对路径是什么?绝对路径的值是什么?@DebanjanB“home\\pierre\\Documents\\python\u projet\\Program\u r\\Video\\over\\”,它位于我知道的Traceback的第二个python行上,并且这个路径存在,因为文件来自os.listdir函数here@Madar使用send_键(os.path.abspath(文件))
send_keys(os.path.abspath(file))