4

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.

0

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

4 Comments

That worked, thank you! How did you know the element id was 'file'? I couldn't seem to locate it on the html when I inspected the element
If there is a form for file upload then there definitely should be <input type="file"> element. You can do driver.find_element_by_xpath('//input[@type="file"]').get_attribute('outerHTML') to check how it looks like
Hm I see, so you knew that the element id = 'file' because there is an option to upload the file?
No. I just know for sure that there is an input node. The attributes (including @id) I can get from outer HTML of element with get_attribute('outerHTML')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.