exception - org.openqa.selenium.WebDriverException: unknown error: cannot focus element on trying to upload a file in selenium -


i trying upload file in webpage through selenium webdriver, , have written below code

driver.findelement(by.cssselector("#collapsedocuments > div > button.button.ng-isolatescope")).sendkeys("c:\\users\\siva.247588\\desktop\\clarient+aml+questionnaire.docx"); 

the css selector of browse button.

i getting below error whwn run this:

exception in thread "main" org.openqa.selenium.webdriverexception: unknown error: cannot focus element

what wrong code? 1 advise?

when try upload file, control shifted our local machine website writing scripts.

so normal click method , select method won't work. can use robot method browse , upload file local machine websites.

hope you..

see below link help: http://www.seleniumeasy.com/selenium-tutorials/webdriver-file-upload-using-robots

i've used somewhere , hope can relate this:

robot rb = new robot();

    rb.keypress(keyevent.vk_a);     rb.keyrelease(keyevent.vk_a);      rb.keypress(keyevent.vk_l);     rb.keyrelease(keyevent.vk_l);      rb.keypress(keyevent.vk_e);     rb.keyrelease(keyevent.vk_e);      rb.keypress(keyevent.vk_r);     rb.keyrelease(keyevent.vk_r);      rb.keypress(keyevent.vk_t);     rb.keyrelease(keyevent.vk_t);     thread.sleep(4000l);      rb.keypress(keyevent.vk_tab);     rb.keyrelease(keyevent.vk_tab);     thread.sleep(4000l);      rb.keypress(keyevent.vk_enter);     rb.keyrelease(keyevent.vk_enter); 

this browse , upload file name "alert"

if need more help, kindly provide me code , want upload , i'll resolve issue.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -