Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selenium file upload without <input type="file"> element

I'm trying to upload my resume using selenium/python over here , under the Resume/CV Attach part.

When I inspect the Attach element, it shows up as <a data-source="attach" href="#">Attach</a>.

I'm not too familiar with HTML so I've tried finding the element by xpath, using send_keys() to upload the file but it runs through the program and doesn't upload anything. No error messages.

driver.find_element_by_xpath('/html/body/div[1]/div/div[1]/div[3]/form/div[1]/div[10]/div/div[3]/a[1]').send_keys(info.resume)

I can manage to find the web element and use click() to open the upload file options up but I want to be able to fully upload a file.

It seems like the example online upload when the input type="file", which I've used before and works fine.

like image 308
help please Avatar asked Oct 31 '25 18:10

help please


1 Answers

Actually there is an input for file uploading. You can use below code:

driver.find_element_by_id('file').send_keys(info.resume)

Note that all 3 file input fields (CV, Cover letter and Unofficial copy of your transcript) have the same id attribute "file", so you can select each by index:

driver.find_elements_by_id('file')[0].send_keys(info.resume)
driver.find_elements_by_id('file')[1].send_keys(info.cover_letter)
driver.find_elements_by_id('file')[2].send_keys(info.transcript)
like image 138
Andersson Avatar answered Nov 03 '25 07:11

Andersson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!