selenium - Error on file size when uploading the image -


i trying upload file using following script. script uploads file via browse button, when click on upload button, gives error //error on file size.

fyi - manually upload same file successful

my script:

driver.findelement(by.xpath(".//*[@id='fileuploadinput']/div/div[2]/input[2]")).sendkeys(file_upload); driver.findelement(by.id("btncreativehostingfileupload")).click(); 

html:

<tr id="fileoas" style="display: table-row;"> <td align="left" style="height:25px;">file name</td>                                                                             <td nowrap="" align="left" style="height:40px;"> <input type="hidden" style="width:250px" name="uploadfilename" id="videouploadfilename" value="tag.png"> <div onclick="setactiveuploadforuploadall();" style="height:40px;"> <!-- <iframe id="suploadall" name="suploadall" onmouseover="setactiveupload('suploadall');" --> <iframe width="470" height="40" frameborder="no" allowtransparency="true" scrolling="no" src="/richmedia/oas/fileupload.do?nextaction=/oas/adwizard.banner.update.do&amp;currentpage=/oas/adwizard.creative.index.do&amp;filecategory=image&amp;fieldname=videouploadfilename&amp;previousfile=" onmouseover="prepareactiveupload('suploadall');" name="suploadall" id="suploadall"> </iframe> <input type="hidden" name="videouploadfilenamefullurl" id="videouploadfilenamefullurl" value="tag.png">  <input type="hidden" name="videouploadfiledownloadurl" id="videouploadfiledownloadurl"> <input type="hidden" value="" id="currentselectfileid"> <input type="hidden" value="" id="currentselectfiletype">  <input type="hidden" name="uploadfilenamefullurl" id="uploadfilenamefullurl" value="tag.png"> <input type="hidden" name="dimensionwidth" id="dimensionwidth">  <input type="hidden" name="dimensionheight" id="dimensionheight"> </div> </td>                                                                            </tr>   <div>     <div class="input_div">         <input type="text" readonly="readonly" class="file_input_textbox" id="filename">     </div>     <div class="file_input_div">         <input type="button" value="browse" class="file_input_button">         <input type="file" style="width:100px;" onchange="javascript: document.getelementbyid('filename').value = this.value" value="" size="25" name="thefile">     </div>     <div class="upload_btn_div">         <button onclick="showprogressandupload(this.form);" name="btncreativehostingfileupload" id="btncreativehostingfileupload" type="button" style="margin-left: 10px" class="btn btn_gray"><div><p>upload</p></div></button>     </div> </div> 

looks using wrong selector

try cssselector

[type='file'] 

or, input tag has name well. can use thefile by.name

so, far in that's file input tag seeing in html have provided

you can javascript executor in case above not work

string filepath = "the filepath extension"; ((javascriptexecutor)driver).executescript("document.getelementbyid('filename').setattribute('value', '"+filepath+"');"); driver.findelement(by.id("btncreativehostingfileupload")).click(); 

Popular posts from this blog