-1

I have been writing the script to fill a form using Selenium with Python. I would like to attach an image file to it. So when I reach the button to upload the file and click it, I no longer can use Selenium to find the element.

I need to figure out how to enter the path to the image file, select it and upload it.

Please look at the image below to get a clear picture of what I am trying to do and let me know the solution.

enter image description here

Shubham Jain
  • 13,158
  • 9
  • 60
  • 102
Optimal Myk
  • 1
  • 1
  • 1

1 Answers1

2

You can even try directly with send_keys function on Browse button that us used to select file. It doesn't involves any windows popup handling.

Example:

import os


driver.find_element_by_id("#button_id").send_keys(os.getcwd() + "/image.png")
Kalob Taulien
  • 1,457
  • 14
  • 18
SunilThorat
  • 1,344
  • 9
  • 13