eclipse - 文件上传的自动代码在 selenium 中不起作用。输入路径后 Windows 消失
问题描述
在 Eclipse 中运行 Autoit 代码时,我遇到了一个奇怪的问题。
我在编译以下代码以在弹出窗口中上传文本文件后创建了一个 exe 文件
如果我在窗口屏幕处于活动状态的命令提示符下手动运行此 exe 文件,则该文件已成功上传到应用程序
如果我通过eclipse运行相同的exe代码我可以看到按钮被按下并且窗口消失(并且没有上传文件)
我尝试将第 4 行更改为 send("{ENTER}") 仍然没有运气
1.WinWaitActive("Open") //Open is the window name
2.Send("C:\Users\AB\Desktop\sampleupload.txt",@SW_SHOWNORMAL) //this works in eclipse
3.WinWaitActive("Open")//this works
4.ControlClick("Open","","Button1") //Button clicked correctly
Runtime.getRuntime().exec("filesend.exe")//code used in eclipse to run the autoit exe file
执行 exe 文件后应该上传文件,但是窗口消失并且没有上传文件。问题仅在通过 eclipse 运行时发生
解决方案
嗨尝试filesend.exe
使用提升的权限运行您(例如管理员)
Runtime.exec("runas /user:adminUser filesend.exe");
推荐阅读
- javascript - 将用户输入存储到 localStorage
- java - 返回 ArrayList Java 中的列表
- javascript - Ajax 调用得到 200 但我没有在函数调用后插入记录
- numpy - 将numpy数组堆栈与自身的hermitian转置相乘而无需循环
- php - PHP,如何显示第二个表
- python - 如何检测闪存驱动器上是否有足够的存储空间来写入文件?
- grails - Aspose:设置页眉时看不到&符号(&)之后的文本
- python - 为什么我的绘图图将 x 轴上的日期时间绘制为指数?
- spring-boot - 在服务器上实施信任库管理器以验证对等 X509 证书
- laravel - 实例化类的关系 - Laravel/Eloquent