Home > Net >  Upload file in selenium, python
Upload file in selenium, python

Time:11-27

I ask for help in solving my problem. Sorry for any mistakes but this is the first time I ask a question. I have a problem with uploading the file in selenium. I was looking for solutions to my problem but I haven't found it.

This is my html code:

<div id="scans-attachments__file__passport-container" >
    <input type="hidden" name="scans[attachments__file__passport]" value="" id="scans-attachments__file__passport">
    <div  data-style-button-remove-item-position="left" data-style-button-process-item-position="right" data-style-load-indicator-position="right" data-style-progress-indicator-position="right" data-style-button-remove-item-align="false" style="height: 76px;">
        <input  type="file" id="filepond--browser-2ybdvwfwp" name="filepond">
    </div>
</div>

i try to do it:

import os
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys

driver.find_element(By.ID, "filepond--browser-2ybdvwfwp").send_keys(os.getcwd()   "/image.jpg")

I get:

response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: [id=\\"filepond\\"]...ntent/shared/webdriver/Errors.jsm:393:5\\nelement.find/</<@chrome://remote/content/marionette/element.js:299:16\\n"}}'}

I'm sorry for not formatting but I'm blind

CodePudding user response:

The error message...

"error":"no such element","message":"Unable to locate element: [id=\\"filepond\\"]

...says the id = filepond is not available on DOM. I am not sure why the remaining value is truncated. Please try with below element,

find_element(By.NAME, "filepond")
  • Related