Upload file with Selenium in Python

前端 未结 6 1070
我在风中等你
我在风中等你 2021-01-14 19:14

Is it possible to upload file attachment with selenium in Python script?

6条回答
  •  礼貌的吻别
    2021-01-14 19:55

    A simple method to upload files is by using pyautogui. You can install pyautogui through pip

    import pyautogui
    ... # set the webdriver etc.
    ...
    ...
    
    self.driver.find_element_by_id("Open file selector").click()# This opens the windows file selector
    pyautogui.write('C:/path_to_file') 
    pyautogui.press('enter')
    

提交回复
热议问题