Upload file with Selenium in Python

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

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

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-14 19:44

    button = driver.find_element_by_xpath("xpathToYourButton")
    button.send_keys("fullPathToFile")
    

    Now if you are in windows path to file uses backslash. To avoid issues use double backslashes! C:\ \Users\ ****\ \Desktop\ \1.jpg without spaces.

    PS. I know its a from 4 years ago but I have been trying to figure this out for some time and someone might find this usefull...

提交回复
热议问题