有人可以告诉我在框架切换完成后如何继续引用 iframe 中的元素吗?我已经查看了How to switch iframes InternJS中提出的解决方案,但无济于事,并且intern Functional Testing with Frames中的信息不适用(尚不适用。)以下脚本返回错误Cannot read property 'apply' of undefined type: TypeError
:
return Remote
.findAllByTagName('iframe')
.then(function (frames) {
return new Remote.constructor(Remote.session)
.switchToFrame(frames[0])
.getProperty('title')
.then(function (result) {
expect(result).to.equal('Rich text editor, rtDescAttach');
});
});
我可以看到脚本失败的唯一原因是框架的位置不正确。页面上有两个,我需要第一个。完成此操作后,我真的很想将对框架的引用放在页面对象中(这是我认为它所属的地方),但我必须能够首先成功找到它,所以不要本末倒置。非常感谢您的建议和帮助。