繁体   English   中英

CasperJS:如何单击关闭页面的框架中的链接,没有错误

[英]CasperJS: How to click a link in a frame that closes the page, without error

我有一个表单我正在填写,其中一个字段需要从弹出窗口中的列表中选择一个对象。 该列表位于弹出页面上的iframe内,单击列表中的链接将关闭弹出窗口并将值放在原始页面上的表单中。

我的问题是我的设置我点击iframe中的链接杀了弹出窗口,然后退出this.withFrame()函数我得到错误

Error: cannot access member 'switchToParentFrame' of deleted QObject

这大致是我的代码的样子。

this.withPopup(/popup/, function() {
    this.withFrame('listFrame', function() {
        // do stuff to get the right link selector
        this.click(link);
    });
});

如果有办法点击withFrame()函数外部的链接?

解决方法是使用PhantomJS函数page.switchToFrame()page.switchToParentFrame()并显式检查page是否仍然有效。 也许甚至不需要检查,因为page实例已经被销毁。

this.withPopup(/popup/, function() {
    this.page.switchToFrame('listFrame');
    this.click(link);
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM