2017-12-11 3 views
1

分裂器5.2.0(ノード8.4.0、角度1.5)でng-repeatループ内の要素の位置を特定できません。 UIコードは次のようなものになります。分裂器を使用してng-repeat-startループ内の要素を見つけることができません

<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: Index out of bound. Trying to access element at index: 0, but there are only 0 elements that match locator by.repeater("app in appsData.result")

を取得しています(私はまた、tagNameを= MDを試してみましたボタン)

私はbrowser.getPageSource()を行った しかし、私は私が分度器することはかなり新しいです

<tbody> 
<!-- ngRepeat: app in appsData.result --> 
</tbody> 

は、任意の助けをいただければ幸いです参照してください!

私の分度器のconfファイルは次のようになります。クラスは=一意である、あなたが試すことができ、 "縁取り" 場合

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 
    } 
}; 

答えて

0

var rows = element.all(by.css('[class="bordered"]')); 
rows.first().element(by.css('md-button')).getText().then(function(text){ 
    console.log("Text: "+text); 
}); 

はそれが

0

はこれを試してみてくださいホープ

var rows = element.all(by.css('[class="bordered"]')); 
rows.first().element(by.css('md-raised.primary')).getText().then(function(text){ 
console.log("Text: "+text); 
}); 

Als xpathまたはクラス名が選択できない場合は、

element(by.className("md-raised primary")) 
+0

ありがとうございます。残念ながら、いずれの方法も機能していません。私は[12:21:54] E /ランチャーを手に入れました。インデックス:0の要素にアクセスしようとしていますが、ロケータに一致する要素は0個だけです(CSSセレクタ、[class = "bordered"]) [12:21:54] E/launcher - NoSuchElementError:インデックス:0の要素にアクセスしようとしましたが、ロケータに一致する要素が0個しかありませんBy(css selector、[class = "bordered"]) – Vishal

関連する問題