如何处理硒在Windows 7文件上传 [英] How to handle file upload in selenium in windows 7

查看:178
本文介绍了如何处理硒在Windows 7文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用硒的webdriver和NUnit自动化我的web应用程序编写脚本。我要上传的文件在我的应用程序。但无法做到这一点。

打开对话框,而浏览按钮被点击,并在选择文件的文件上传

浏览

如何能做到这一点的硒?


解决方案

 公共无效uploadFile(字符串locatorId,字符串文件路径){WebElement的FileInput = findElementExplicitWaitWithNoVisbility(By.id(locatorId),TRUE);fileInput.clear();
fileInput.sendKeys(文件路径);}

I am writing a script in selenium using webdriver and nunit to automate my web application. I have to upload file in my application. But unable to do it.

The dialog opens while browse button is clicked, and upon selecting file the file is uploaded.

Browse

How can i do it in selenium?

解决方案

public void uploadFile(String locatorId, String filePath) {

WebElement fileInput = findElementExplicitWaitWithNoVisbility(By.id(locatorId), true);

fileInput.clear();
fileInput.sendKeys(filePath);}

这篇关于如何处理硒在Windows 7文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆