1

I am trying to click a button that brings up a dialogue box to select a file. inspecting the element it looks like its an input rather than a button. Either way I cannot click it with:

element = browser.find_element_by_id("fileupload")
element.click()

and

browser.find_element_by_id("fileupload").send_keys("\n")

Neither of which seem to work.

Here is what I see when I inspect that element on the page:

<span class="btn btn-success fileinput-button">
  <span class="glyphicon glyphicon-upload"></span> 
    Select and Upload...
  <input id="fileupload" name="upfile" accept=".xml" type="file">
</span>

Any assistance help or pointers would be appreciated!

1 Answer 1

2

Clicking on a file input usually triggers a file upload dialog. Since you cannot control it with selenium, you need to avoid the dialog being opened by sending keys to the input instead:

browser.find_element_by_id("fileupload").send_keys("path_to_the_file")

See also:

Sign up to request clarification or add additional context in comments.

Comments

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.