简体   繁体   English

theintern测试框架-测试iframe

[英]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.

相关问题 Intern测试框架异步设置 - TheIntern test framework asynchronous setup TheIntern测试框架下加载Dojo AMD模块失败 - Loading Dojo AMD module fails under TheIntern test framework 配置实习生仅用于单元测试 - Configure theintern for unit testing only 如何在Chai测试框架中测试数组? - How to test for arrays in chai testing framework? The Intern.IO测试运行程序实习客户机问题“试图要求卸载模块超级代理” - TheIntern.IO test runner intern-client issues “Attempt to require unloaded module superagent” 使用PhantomJS测试不友好的iframe中的元素 - Testing elements inside unfriendly iframes with PhantomJS 单元测试带有页面重新加载和iframe的JS应用程序 - unit testing JS app with page reloads and iframes 在无头模式下测试嵌套 iframe 时出现赛普拉斯错误 - 竞争条件 - Cypress error when testing nested iframes in headless mode - race condition Javascript Testing Framework是关于测试javascript代码还是使用javascript测试以某种其他编程语言编写的任何应用程序? - Is Javascript Testing Framework about testing javascript code or using javascript to test any application written in some other programming language? 是否可以在客户端启动测试框架以测试本地网络中的其他应用 - Is possible Launching testing framework on client side to test other app in local network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM