javascript - 使用 element.all 遍历表时量角器抛出 StaleElementReferenceError
问题描述
我有量角器测试,它将在一个有 6 列的表上进行迭代。我正在使用 element.all 在表上进行迭代,然后在第一列中搜索特定文本。如果匹配,请检查第 6 列中的状态,如果设置为激活,单击匹配的行将其转到另一个页面,执行操作,返回表页面,在同一个表上重复并检查该特定文本并再次验证最终状态为激活。
测试运行良好,但失败并出现以下错误。
StaleElementReferenceError: stale element reference: element is not attached to the page document
element.all(by.css('tbody tr')).each(function(item){
var count=0;
var pass=0;
//TEST VALUES BELOW
var appNameCreated="Test App 534";
//TEST VALUES ABOVE
item.element(by.css('td:nth-child(1)')).getText().then(function(appname){
if(appname==appNameCreated){
console.log(appname,appNameCreated);
item.element(by.css('td:nth-child(6)')).getText().then(function(result){
pass += 1;
console.log(result);
if (result=="Activated"){
//if (result==data.resultSubmit){
item.element(by.css('td:nth-child(1)')).element(by.css('a')).click().then(function(){
browser.sleep(4000);
});
element(by.id("btnTab3")).element(by.xpath('span')).click();
browser.wait(EC.visibilityOf(element(by.xpath('/html/body/gft-root/section/div[2]/app-onboard-list/div[4]/div[3]/table/tbody/tr[1]/td[1]'))),15000);
element(by.id("button-basic")).click();
element.all(by.css('ul[class="dropdown-menu"]')).each(function(item1){
item1.element(by.css('li:nth-child(7)')).element(by.css('a')).click();
})
element.all(by.css('tbody tr')).each(function(item2){
item2.element(by.css('td:nth-child(1)')).getText().then(function(appname1){
if(appname1==appNameCreated){
item2.element(by.css('td:nth-child(6)')).getText().then(function(resultFin){
console.log(resultFin);
browser.actions().mouseMove(item2.element(by.css('td:nth-child(1)'))).perform();
expect(resultFin).toBe(data.resultFinal);
})
}
})
})
}
})
}
})
})
解决方案
推荐阅读
- errbot - 如何忽略errbot中的特定消息或用户?
- mysql - 实体框架Mysql慢查询
- docker - 代理 kubernetes 通过代理 (CNTLM) 的传出流量
- java - FilterList 与 RowFilter 与 HBase 上的 MultiGet 之间的区别
- c# - 如何使用 ListBlobsSegmentedAsync 从 Azure BLOB 中的目录中获取所有文件
- java - 关于春季的classpath:/META-INF/resources
- android - 在 Ejabberd/XMPP 中同时禁用多个设备的用户登录
- angular - 默认值在“select”中显示为空
- c# - 使用 c# asp.net 获取 XML 数据并插入到 sql server
- python - 没有 IO 操作的 Trio 执行时间