访问iframe中的文件对话框

时间:2012-06-06 23:34:49

标签: selenium selenium-webdriver

我有一个内联jsp页面,其中包含html type:file的代码。以下显示的IFRAME标记位于主jsp中。我想传递文件名并使用Web驱动程序提交此文件对话框。基本上想要做的事情如下:

WebElement elem = driver.findElement(By.id("attachmentfile"));        
elem.sendKeys("C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg");

但是,我无法获得附件文件ID。任何帮助,将不胜感激。感谢。

Main Jsp:

<IFRAME id=fileupload src="fileupload.jsp?type=uploadbutton"
frameBorder=0></IFRAME></TD></TR></FORM>

fileupload.jsp如下:

    <html> <body>
    <form name="frm_fileUpload" ENCTYPE="multipart/form-data"><%
    <tr>
    <td>
        <input type="file" name="attachmentfile" 
        id="attachmentfile" onChange="uploadFile   ();" />
        <input type="button" name="uploadbutton" id="uploadbutton" 
        value="Upload" class="button" />
    </td>
    </tr>
   </table>
   </form>                
   </body>
   </html>

0 个答案:

没有答案
相关问题