通过Selenium中的窗口提示处理上传文件,C#

时间:2014-05-29 11:28:18

标签: c# selenium selenium-webdriver

尝试打开文件时会出现窗口对话框(如http://www2.warwick.ac.uk/services/its/servicessupport/web/sitebuilder2/faqs/files/upload_multiple/xp_file_browser.png) 所以我需要设置文件路径并单击“确定”按钮。 Selenium没有本机功能。我在java上发现了它的作用:

StringSelection abc= new StringSelection("E:\\Study Materials\\Resume And Cv\\Sample 1_0.doc");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(abc, null);
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

在C#中有类似的支持吗?

1 个答案:

答案 0 :(得分:-1)

我在下面的文章http://cheryjose.blogspot.com/2013/03/how-to-interact-with-dialog-windows.html中找到了答案 - 我发送了路径并输入了按键。

相关问题