如何使用 Autoit 关闭所有可能出现的 javascript 警报和确认?
我正在硒中进行测试,并且在页面加载时发生了很多事情。我发现了 autoit,我认为它可以处理所有 javascript 对话框问题。我在网上搜索一些可以处理这个问题的自动脚本...
其他选项也会有帮助!
我不一定需要所有代码,但正确方向的某些点会有所帮助。
I am testing in selenium and I have a bunch of stuff that happens on page load. I found out about autoit, and I was thinking that it could handle all javascript dialog issues. I was searching around the web for some autoit script that could handle this...
Other options would be helpful as well!
I don't necessarily need all the code, but some point in the right direction would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,这个解决方案对我有用...我可以在这里关闭 2 个窗口。另外,我将能够根据弹出窗口的名称来处理弹出窗口,这很酷。我启动脚本后它总是在后台运行。当我希望它结束时,我只需从任务管理器或右侧任务栏区域关闭自动程序即可。
这也可以直接在 python 中实现,详细信息: http://www.parrisstudios.com/?p =308,但你仍然需要autoit3。
Alright so this solution works for me... I was able to close 2 windows here. Also I will be able to handle popups based on their name which is cool. It always runs in the background after I have lauched the script. When I want it to end I simply close autoit from task manager or from the task bar area on the right.
Also this is possible from directly within python, details: http://www.parrisstudios.com/?p=308, but you still need autoit3.
如果您遇到警报框问题,您可能需要以编程方式禁用它们,或者在代码中创建一个单独的模式,根据条件(即调试模式)将其关闭。
宏录制程序的工作效果并不像您想象的那么好。通常,宏记录程序会记录鼠标单击的位置和按键的时间。更好的宏记录程序使用(通常是图像处理)和(很少)计算机视觉技术。使用这些技术的解决方案通常非常昂贵。 (每个座位 5k-10k) [我不记得更好版本的名称之一 可能是 QuickTest,但它是由一家被 HP 收购的公司制造的]
If you are having issues with alert boxes you might want to disable them programmatically or create a separate mode in your code that would turn them off based on a condition (i.e. debug mode).
Macro recording programs don't work as well as you might think. Typically macro-recording programs record locations of mouse clicks and timing of key presses. The better macro-recording programs use (typically image processing) and (rarely) computer vision techniques. The solutions that use these techniques are typically VERY EXPENSIVE. (5k-10k per seat) [I can't remember one of the names of the better versions Might be QuickTest, but it was made by a company that was bought out by HP]
我试图用 autoit 与网页进行交互,愚蠢的 javascript 警报不断破坏一切,我终于弄清楚如何禁用它们,所以我想我将其发布在这里:
基本上,它的作用是在 autoit 中调用一个函数页面就绪状态='交互式'(显然这是在大部分页面加载之后但在它“运行”我认为的任何内容之前),将一些javascript插入页面以重新定义alert()函数,以便它不执行任何操作(无警报)对话框,不用担心必须单击“确定”)。我已经测试过这个并且它有效。
如果从页面内的框架调用alert()函数,则必须使用框架的onreadystatechange事件和readystate属性,而不是主文档。
I was trying to interact with a webpage with autoit and the stupid javascript alerts kept breaking everything and I finally figured out how to disable them so I thought I would post it here:
Basically what this does is have a function get called in autoit when the page ready status='interactive' (apparently this is after most of the page has loaded but before it "runs" anything i think) that inserts some javascript into the page to redefine the alert() function so that it does nothing (no alert dialog to worry about having to click ok on). I have tested this and it works.
If you have the alert() function being called from a frame inside the page then you will have to use the onreadystatechange event and the readystate property of the frame instead of the main document.