Every time I try, I got error in instruction of the find_element, can someone try upload an image to this specific web site: https://www.custojusto.pt/ai/form/0 and let me know how I can solve this?
def upload():
driver.get('https://www.custojusto.pt/ai/form/0')
#time.sleep(10)
driver.find_element_by_name('image').send_keys("https://images-na.ssl-images-amazon.com/images/I/41pzTMUV7AL._SY300_.jpg")
if __name__ == '__main__':
upload()
First of all you can upload images using urls i believe. You need to download them manually and then upload it. You can download the image using approach discussed on below thread
How to download image using requests
Also your upload part is in a IFrame so you need to switch to Iframe first
from selenium import webdriver
driver = webdriver.Chrome()
def upload():
driver.get('https://www.custojusto.pt/ai/form/0')
#time.sleep(10)
driver.switch_to.frame("image-upload")
driver.find_element_by_name('image').send_keys("/tmp/aws.png")
if __name__ == '__main__':
upload()
driver.quit()
I tested the above code and it works great for me. Note once the image is uploaded , if you need to upload another image, use driver.switch_to.frame("image-upload")
again as a new frame gets created and old isn't valid anymore.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments