Selenium RC上传文件

发布于 2024-09-13 04:18:40 字数 50 浏览 2 评论 0原文

我可以在 IE 中使用 selenium RC 上传文件吗?

can I upload files using selenium RC in IE?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

小镇女孩 2024-09-20 04:18:40

简短的回答是,一般来说您不能。想想看,如果 Javascript 代码可以通过编程方式将文件上传到服务器,那么它就可以在用户没有注意到的情况下将敏感文件发送到服务器。

正如 Niraj 指出的那样,有很多方法可以解决这个问题,但它们涉及使用另一种工具将按键注入窗口系统事件队列。另外,您可以使用*chrome后端运行,即安全屏障较低的*firefox。

The short answer is that in general you can't, due to browser security restrictions. Think about it, if Javascript code could programmatically upload a file to the server, it could send sensitive files to the server without the user ever noticing.

There are ways to work around it, as Niraj notes, but they involve using another tool to inject keypresses into the window system event queues. Also, you can run using the *chrome backend which is *firefox with lower security barriers.

雪化雨蝶 2024-09-20 04:18:40

浏览一下这篇文章。将帮助您在 selenium RC 中上传文件
http://automationtricks.blogspot.com/2010 /09/如何上传文件-in-selenium.html
谢谢
尼拉吉

Go through this post . will help you to upload file in selenium RC
http://automationtricks.blogspot.com/2010/09/how-to-upload-file-in-selenium.html
Thanks
Niraj

偷得浮生 2024-09-20 04:18:40

您可以尝试使用 *iehta 浏览器启动器而不是 *iexplore。 *iehta 拥有更高的特权。我用它来规避“同源”限制,并且我读过的各个论坛中的评论表明它也可能适用于文件上传。

You might try using the *iehta browser launcher instead of *iexplore. *iehta has heightened privileges. I use it to circumvent "Same Origin" restrictions, and comments in various forums I've read indicate that it might work for file upload as well.

终陌 2024-09-20 04:18:40

我发现 Autoit 可以完成这项工作,但对于 Firefox 来说它失败了,所以根据浏览器的 if else 语句出现了。

WinWaitActive("Choose File to Upload")
Send("C:\Images\abc.jpg")
Send("{ENTER}")

Autoit< 的 SciTE 脚本编辑器中键入上述代码/a>.

“选择要上传的文件”是单击按钮(浏览/附加)时窗口的标题。
点击(浏览)之前执行代码时,代码应该执行由将脚本编译为.exe创建的exe文件,以便代码将等待弹出窗口,并且当弹出窗口选择要上传的文件。

I found that Autoit does the job but It failed for firefox so if else statement according to browser comes.

WinWaitActive("Choose File to Upload")
Send("C:\Images\abc.jpg")
Send("{ENTER}")

Type the above code in SciTE Script Editor of Autoit.

The "Choose File to Upload" is the title of the window when you click on button(Browse/Attach).
While Executing the code before click(Browse) the code should be execute the exe file created by Compile Script to .exe so that the code will wait for the popup and when the popup comes it selects the file to upload.

要走干脆点 2024-09-20 04:18:40

在firefox和其他浏览器中,您只需使用selenium的type命令即可上传文件。

请参阅此处 http://aboutselenium.blogspot.com/2011 /02/handling-file-upload-using-selenium.html

In firefox and other browsers you can upload a file just using type command of selenium.

See here http://aboutselenium.blogspot.com/2011/02/handling-file-upload-using-selenium.html

盛夏尉蓝 2024-09-20 04:18:40

我们可以将 Sikuli 与 selenium 一起使用。如果您对解决方案感兴趣,我可以为您提供更好的。请详细说明您的要求。

We can use Sikuli with selenium. If you are int interested in solution I can provide you better. Please explain your requirement in details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文