vendredi 26 février 2021

select random images from a folder for webdriver

I want to uplaod an Image to twitter, I am using selenium
I have a folder where all images are located but I need to choose a random images in that folder Thanks for your help

path_image = ('C:/Users/92/Desktop/python/V2/images/')

    element = driver.find_element_by_xpath("//input[@type='file']")
    driver.execute_script("arguments[0].style.display = 'block';", element)
    
    element.send_keys(random.choice(path_image))

the ERROR that I am getting

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: File not found : D
  (Session info: chrome=88.0.4324.190)



Aucun commentaire:

Enregistrer un commentaire