I have a table with rows and I need to click on the edit button in a row that has a specific label (test server label).
This is my function:
public selectOnRow( textSelector:string , clickableSelector : string , value:string) {
let promise = new Promise(resolve => {
element.all(by.css(textSelector)).each((elem, i) => {
elem.getText().then(function (text) {
if (text === value) {
resolve(i);
}
});
});
});
promise.then(i => {
element.all(by.css(clickableSelector)).get(i).click();
})
}
And this is how I am using it:
beforeAll(async () => {
page = new AppPage;
page.navigateTo('/asset/server');
page.selectOnRow('.column-label div', '.edit-action-btn', 'test server label')
baseUrl = page.baseUrl;
});
The problem arises when the page changes - the selectOnRow
function continues to loop through rows that are no longer on the current page. This results in the following error:
Failed: stale element reference: element is not attached to the page document