how can I upload image to this website with selenium in python

romo

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()
Tarun Lalwani

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to upload an image to a website using selenium python

How to upload an image with selenium python?

Python-Selenium : How can I get access to this part of the website?

How can I parse a website using Selenium and Beautifulsoup in python?

How can I parse a website using Selenium and Beautifulsoup in python?

how can i extract this value from a website, with python, selenium and chromedriver

How can I get a YouTube video upload date with Selenium in Python?

How can i upload my website?

How can I take a screenshot/image of a website using Python?

How can I upload the selected image into the label with using python tkinter?

Python Selenium - How to upload image in this case?

How i can upload image to the article?

How can i upload image with ajax in codeigniter?

How can I upload an image with AJAX?

How can I upload the image file with axios?

How can we upload image from URL in selenium

How can I scrape a website that does not show any HTML codes in the source using Python without Selenium

Amazon website shows "Deliver to Country". How can I change it programmatically in Python Selenium to take screenshots

How can I get the tooltip text from a website using selenium and python where the text comes from a javascript

How can i download specifcs files from a website using Python + Selenium

How can I allow users of my website to upload media files?

Upload a resume to a website using python selenium module

Is a python script to upload a file to website with selenium

How to upload image within a hidden element using Selenium and Python

Can't upload image to website with PHP and MySQL

How can I print an item in a website using selenium

How can I login to a website with Python?

How can I login to an AngularJS website with python?

How can I download and upload an image using a url in django-python 2.7 using urllib 2