0

How do I send a file link to load on the page using selenium?

<input type="file" id="filArquivo" class="infraInputFile" name="filArquivo" size="50" onchange="objUpload.executar();" tabindex="1000">

Does not work:

WebDriverWait(navegador, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="filArquivo"]'))).send_keys("Doc.pdf")

Does not work:

WebDriverWait(navegador, 20).until(EC.element_to_be_clickable((By.ID, 'filArquivo'))).send_keys("Doc.pdf")

Snapshot:

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

Try:

  • Using CSS_SELECTOR:

    WebDriverWait(navegador, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.infraInputFile[name='filArquivo']"))).send_keys("/path/to/Doc.pdf")
    
  • Using XPATH:

    WebDriverWait(navegador, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='infraInputFile' and @name='filArquivo']"))).send_keys("/path/to/Doc.pdf")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
-1

Try to use full path to file (os.path.abspath)

gresaggr
  • 41
  • 1
  • 7
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Akzy Mar 03 '23 at 11:20