java - Selenium WebDriver - unable to upload file with AutoIT -


i'm unable upload file autoit v3

try many ways, no luck work

method one: (get element not visible)

driver.findelement(by.xpath("//input[@type='file']")).click(); runtime.getruntime().exec("d:\\documentation\\script upload file.exe"); 

method two: (get element not visible)

driver.findelement(by.name("filename")).click(); runtime.getruntime().exec("d:\\documentation\\script upload file.exe"); 

method three: (passed: testcaseone, no file uploaded)

driver.findelement(by.id("button2")).click();    runtime.getruntime().exec("d:\\documentation\\script upload file.exe"); 

for attach link, when inspect firepath, refer xpath "html/body/input" 1 matching node

here html file

<input type="file" name="filename" style="position: absolute; margin: -5px 0px 0px -175px; padding: 0px; width: 220px; height: 30px; font-size: 14px; opacity: 0; cursor: pointer; display: none; z-index: 2147483583; top: 457px; left: 459px;"/> 

here's html code document upload section:

<html>     <body>         <div>             <div>                 <form>                     <div>                         <dl>                             <dd class="attachfile">                                 <div class="attachupload">                                     <a id="button2" class=" ">                                         <img class="attachico" alt="" src="http://qa.seleniumqa.com/ga/en/clean/images/blank.gif"/>                                             attach file                                     </a>                                 </div>                             </dd>                         </dl>                     </div>                 </form>             </div>         </div>     </body> </html> 

script upload file.au3 code

; wait 8 seconds appear file upload dialog. ; used title property of file upload dialog window.    winwait("file upload","",8)  ; set control focus file name input box of file upload dialog. ; used class property of file upload dialog window , class+instance property file name input box.    controlfocus("[class:#32770]","","edit1")    sleep(3000)  ; set name of file in file name edit1 field. ; "test.txt" file located in autoit folder of e drive. have provide full path e:\autoit\test.txt.    controlsettext("[class:#32770]", "", "edit1", "d:\documentation\uploadfile.xls")    sleep(3000)  ; click on open button of file upload dialog.    controlclick("[class:#32770]", "","button1"); 

edit: share solution needed in future

this code not working (not sure why)

driver.findelement(by.id("button2")).sendkeys("d:\\documentation\\uploadfile.xls"); 

but in way, work

driver.findelement(by.id("button2")).click(); driver.findelement(by.xpath("//input[@type='file']")).sendkeys("d:\\documentation\\uploadfile.xls"); 

the type of input control file , therefore, using below line upload file should work.

webelement e = driver.findelement(by.id("the id")); e.sendkeys("file path"); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -