[英]theintern test framework - testing iframes
im creating a platform to user automated tests to verify if a widget is functional. 我为用户自动测试创建了一个平台,以验证小部件是否正常运行。 I already made the tutorials and the saw the examples but still i can figure out what's happening. 我已经制作了教程并看到了示例,但仍然可以弄清楚发生了什么。
the widget that im trying to test is made with iframes without src attribute and with im trying to find a element inside of that iframe without src attribute.`define(function (require) { var registerSuite = require('intern!object'); var assert = require('intern/chai!assert'); 我要测试的小部件是用不带src属性的iframe制作的,而我要在不带src属性的iframe内查找元素的方法。define(function(require){var registerSuite = require('intern!object'); var assert = require('intern / chai!assert');
registerSuite({
name: 'index',
'greeting form': function () {
return this.remote
.get(require.toUrl('localhost:3000'))
.findById('iframeId')
.switchToFrame('iframeId')
.findById('buttonID');
}
});
});` });`
With this code it happens that the intern runner returns a error saying that it wasn't unable to find the element. 使用此代码,实习生运行程序会返回一个错误,指出它无法找到该元素。 But when i try to run the same code on a iframe with a "src" attribute it finds the correct element and doesn't returns any error. 但是,当我尝试在具有“ src”属性的iframe上运行相同的代码时,它会找到正确的元素,并且不会返回任何错误。
anyone could help ?? 任何人都可以帮助?
In the above code, you should clear the search context before trying to find an element in the iframe, like: 在上面的代码中,您应该先尝试清除搜索上下文,然后再尝试在iframe中查找元素,例如:
return this.remote
.get(require.toUrl('localhost:3000'))
.findById('iframeId')
.end()
.switchToFrame('iframeId')
.findById('buttonID')
This is assuming the findById
call is to wait for the iframe to be added to the page. 假设findById
调用要等待将iframe添加到页面中。 If you don't need to do that, just leave out the findById('iframeId')
call and you should be good. 如果您不需要这样做,只需忽略findById('iframeId')
调用即可,您应该会很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.