[英]TheIntern.IO test runner intern-client issues “Attempt to require unloaded module superagent”
[英]TheIntern.io/Selenium elementByCssSelector Only Works Once
我遇到一个奇怪的问题,当我通过Selenium(使用Intern.io框架)运行功能测试时,只能识别第一个元素。 我尝试访问后的任何元素均返回以下错误:
Error: Error response status: 7
我知道此回复可以解决:
{summary:'NoSuchElement',
detail:'An element could not be located on the page using the given search parameters.'}
由于我知道该元素绝对可用,因此此错误令人沮丧。
这是我失败的简单功能测试:
define([
'intern!object',
'intern/chai!assert',
'require'
], function (registerSuite, assert, require) {
registerSuite({
name: 'search',
'geocode search test': function () {
return this.remote
.get('http://localhost:8181')
.elementByCssSelector('.modal-close').clickElement()
.elementByCssSelector('#location_search_field').clickElement().type('San Francisco, CA')
}
});
});
该测试将找到.modal-close
元素,并适当地单击它,但是,在它返回尝试查找#location_search_field
元素的错误(抛出上面提到的错误)之后,将返回该错误。
如果我注释掉.elementByCssSelector('.modal-close').clickElement()
行,则selenium不会发现位置输入字段并使用提供的字符串填充它。
我也尝试了elementById('location_search_field')
。
如果您想了解我的环境数组,请复制以下内容:
environments: [
{
browserName: 'firefox',
platform: 'MAC',
cssSelectorsEnabled: true,
javascriptEnabled: true,
applicationCacheEnabled: true,
webStorageEnabled: true
}
]
任何帮助将不胜感激。
自以为知道了,我就发布答案了。 我了解到,只要在每次浏览器操作后添加.end()
,测试就可以按照我期望的那样继续运行。
这是我示例中的更新代码:
define([
'intern!object',
'intern/chai!assert',
'require'
], function (registerSuite, assert, require) {
registerSuite({
name: 'search',
'geocode search test': function () {
return this.remote
.get('http://localhost:8181')
.elementByCssSelector('.modal-close').clickElement()
.end()
.elementByCssSelector('#location_search_field').clickElement().type('San Francisco, CA')
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.