【发布时间】:2017-12-11 17:50:02
【问题描述】:
我无法使用量角器 5.2.0(节点 8.4.0,角度 1.5)在 ng-repeat 循环中定位元素。 UI 代码如下所示:
<tr ng-repeat-start="app in appsData.result" class="bordered">
<td>
<md-button id="{{app.name}}" class="md-raised primary" ng-click="appAction('configure', app)">
Configure and Run
</md-button>
</td>
</tr>
<tr ng-repeat-end ng-show="expanded" ng-class="{'highlighted': expanded}">
..... 我试过了
var rows = element.all(by.repeater("app in appsData.result"));
rows.first().element(by.tagName("button")).getText().then(function(text){
console.log("Text: "+text);
});
但我得到了一个
[12:24:40] E/launcher - NoSuchElementError:索引超出范围。试 访问索引处的元素:0,但只有 0 个元素 匹配定位器 by.repeater("app in appsData.result")
(我也试过 tagName = md-button)
我做了一个 browser.getPageSource() 但我只看到
<tbody>
<!-- ngRepeat: app in appsData.result -->
</tbody>
我是量角器的新手,任何帮助将不胜感激!
我的量角器配置文件如下所示:
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
getPageTimeout: 600000,
allScriptsTimeout: 5000000,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('protractor-cucumber-framework'),
capabilities: {
browserName: 'chrome',
'chromeOptions': {
args: ['--no-sandbox', 'headless']
}
},
// Spec patterns are relative to this directory.
specs: [
'features/*.feature'
],
baseURL: 'http://localhost:8080/',
cucumberOpts: {
require: 'features/step_definitions/*.js',
tags: false,
format: 'pretty',
profile: false,
'no-source': true
}
};
【问题讨论】:
标签: angularjs protractor