How To Upload Image With Angular Components Using Python Selenium
My automation script needs to upload an image to the webpage but I can't seem to upload the image using the normal send_keys method. I suspect it has something to do with the Angul
Solution 1:
To handle windows object you can use autoit
However there is Python binding for AutoItX3.dll
You need to install PyAutoIt
using pip.
pip install -U pyautoit
You need to import autoit on your python scripts.
import autoit
Click on the chose file
button first.
driver.find_element_by_xpath("//button[@type='button'][contains(.,'Choose file')]").click()
Then add the following code with the relevant file path
filepath="C:\\filelocation\\filename.jpg"
autoit.win_wait_active("File Upload",5)
if autoit.win_exists("File Upload"):
autoit.control_send("File Upload","Edit1",filepath+"{ENTER}")
Let me know if you need further assistance.
Post a Comment for "How To Upload Image With Angular Components Using Python Selenium"