0

I tried WebDriverWait(browser, 30).until(EC.visibility_of_element_located((By.CLASS_NAME, "upload-file dropzone"))).send_keys(r"C:\Users\Dln\Desktop\wide.jpg")

but I got nothing uploaded, it is clickable and it opens a window to choose the image from my system, I tried to use keyboard.type(path) after clicking the upload image button but it is not that efficient, so I was wondering about other methods.

here's the code for the button

<div class="fileinput-button">
<div class="file-input">
<div class="kv-upload-progress kv-hidden" style="display: none;"><div class="progress">
    <div class="progress-bar bg-success progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width:0%;">
        0%
     </div>
</div></div>
<div class="clearfix"></div>

<button type="button" tabindex="500" title="Abort ongoing upload" class="btn btn-default btn-secondary kv-hidden fileinput-cancel fileinput-cancel-button legitRipple"><i class="glyphicon glyphicon-ban-circle"></i>  <span class="hidden-xs">Cancel</span></button>

<div tabindex="500" class="btn btn-link btn-sm text-default font-weight-semibold btn-file legitRipple"><i class="icon-upload4 mr-2"></i>  <span class="hidden-xs">Upload images</span><input type="file" name="file" id="upload-file-wysiwyg-btn" class="file-input file-input-custom form-control form-control-sm alpha-grey" multiple="multiple" data-browse-icon="<i class='icon-upload4 mr-2'></i>" data-browse-label="Upload images" data-show-caption="false" data-show-upload="false" data-browse-class="btn btn-link btn-sm text-default font-weight-semibold" data-remove-class="btn btn-light btn-sm" data-show-remove="false" data-show-preview="false" data-fouc=""></div>
</div>
</div>

2 Answers 2

1

An alternative and effective way to upload with file path

import os
driver.find_element_by_id("field_id").send_keys(os.getcwd()+"\wide.jpg")
Sign up to request clarification or add additional context in comments.

3 Comments

I got that error selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: File not found even though I am sure of the path
I solved it, thanks a lot, I had to add \imagename.png not the whole path
@Amr Awesome ! Happy Learning :)
0

Sometimes the element can be visible, but not yet clickable. Try using

EC.element_to_be_clickable

as the wait condition.

6 Comments

I got that as an error selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable
I'm not sure you are using the right element. Try using file-input instead of upload-file dropzone as the class-name selector.
WebDriverWait(browser, 30).until(EC.element_to_be_clickable((By.CLASS_NAME, "fileinput-button"))).send_keys(r"C:\Users\Dln\Desktop\wide.jpg") I used this, I actually pretty much tried every possible class name in the HTML that belongs to that button
Are you able to share url to the page?
You gotta have an ID and PW for that as it is a back-end website, do you have any social media accounts or an email that I can pass you the ID and PW on ?
|

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.