3

I am trying to use Selenium to automatically add a file on this twitter link .

I have found that I can do this by doing:

    # filePath is a proper path to an image
    uploadPhoto = driver.find_elements_by_name('media_empty')[1]
    uploadPhoto.send_keys(filePath) 

However, I need to be able to do the same thing using Selenium's 'execute_script' command. I have tried the following, but it's not working:

    uploadPhoto = driver.find_elements_by_name('media_empty')[1]
    driver.execute_script('arguments[0].innerHTML=\'' + filePath + '\';', uploadPhoto)

Any ideas on how to add a photo the execute_script command and some JavaScript?

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Stuart C
  • 165
  • 3
  • 9

0 Answers0