0

I am new automation and I am using selenium with python and got stuck.

I am trying to upload the document using sendkeys in selenium but getting this error.

Error -selenium.common.exceptions.WebDriverException: Message: unknown error: cannot focus element.

Section where i am trying to upload the document ::

Upload document GUI

Below is the html code:

<spane class="uk-form-file md-btn" style="width:70%;height: 50%">
                                                Upload Document
<input type="file" ngf-select="" id="picture_ids" class="md-input ng-pristine ng-invalid ng-invalid-required ng-touched" onchange="angular.element(this).scope().imageUpload(this.files,'picture','document')" name="picture" ng-model="statusUpdate.document" style="width: 100%;" ng-required="true" required="required">
<br>
</spane>

and corresponding Selenium code:

uploaddoc=wait.until(EC.presence_of_element_located((By.XPATH, "//spane[@class='uk-form-file md-btn']")))
uploaddoc.send_keys("C:/PycharmProjects/Auc/dummy.pdf")
2
  • Your HTMl code has syntax error its like <spane>. Is there any <spane/> tag actual sytax is <span/> Commented Aug 21, 2020 at 10:00
  • Thanks @MohamedSulaimaanSheriff Commented Aug 21, 2020 at 10:47

1 Answer 1

2

You are trying to sendKEys to a span element ,

instead you have to use input element.

try using :

uploaddoc=wait.until(EC.presence_of_element_located((By.XPATH, "//input[@id='picture_ids']")))
uploaddoc.send_keys("C:/PycharmProjects/Auc/dummy.pdf")
1
  • 1
    thanks @PDHide . its working. Commented Aug 21, 2020 at 11:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.