元素未附加到页面文档,同时异步函数 运行
element not attached to page document, async functions running simultaneously
我无法解决以下问题,也找不到任何相关信息,所以是时候 post 这里:
我有如下一段代码
const smdb = new SmdbPage;
const edit = new SmdbEdit;
describe('SMDB Edit:', () => {
it('should navigate to SMDB, select random',
async () => {
await smdb.navmenu(smdb.tooltipName.smbd);
await smdb.getFirst();
});
it('Should edit edu & training', async () => {
await edit.clearEduTrain();
await edit.edu();
await edit.train();
});
});
我有以下 class:
export class SmdbEdit extends BasicEdit {
EDUCATIONSANDTRAINING = element(by.testId('educationsTrainings'));
CVCOMMISSONBOX = element(by.testId('cvCommissionBox')).element(by.className('ibox-content'));
SKILLSBOX = element(by.testId('skills'));
// cv comission
VS = this.CVCOMMISSONBOX.element(by.testId('validationStatus')).all(by.className('ng-valid')).first();
cvSave = this.CVCOMMISSONBOX.element(by.testId('SaveBtn'));
CT = this.CVCOMMISSONBOX.element(by.testId('cvCommissionCampaignID'));
// Education
dateStart = this.EDUCATIONSANDTRAINING.element(by.testId('dateStart')).element(by.css('[autocorrect="off"]'));
dateEnd = this.EDUCATIONSANDTRAINING.element(by.testId('dateEnd')).element(by.css('[autocorrect="off"]'));
institution = this.EDUCATIONSANDTRAINING.element(by.testId('institution'));
qualifications = this.EDUCATIONSANDTRAINING.element(by.testId('qualification'));
eduTypeUntouched = this.EDUCATIONSANDTRAINING.element(by.testId('type'));
eduTypeTouched = this.eduTypeUntouched.element(by.css('[autocomplete="false"]'));
// Profession
yearSelect = this.EDUCATIONSANDTRAINING.element(by.testId('yearSelect'));
organisation = this.EDUCATIONSANDTRAINING.element(by.testId('organisation'));
training = this.EDUCATIONSANDTRAINING.element(by.testId('training'));
async clearEduTrain() {
browser.wait(
this.EC.urlContains('/smdb/edit/')
).then( async () => {
const arr: ElementArrayFinder = element.all(by.testId('deleteRow'));
arr.each( async (e: ElementFinder) => {
await browser.sleep(1000);
await e.mouseHoverClick();
});
});
}
async edu() {
await browser.sleep(1000);
await this.dateStart.sendKeys('2001-01-01');
await this.dateEnd.sendKeys('2002-01-01');
await this.qualifications.secureSendKeys('testQualification');
await this.institution.secureSendKeys('testInstitution');
await this.eduTypeUntouched.mouseHoverClick();
await this.eduTypeTouched.secureSendKeys(protractor.Key.ENTER);
await this.save(0);
}
async train() {
await this.yearSelect.mouseHoverClick();
await browser.sleep(1000);
await this.yearSelect.sendKeys(protractor.Key.ENTER);
await this.organisation.secureSendKeys('testOrg');
await this.organisation.secureSendKeys('testTraining');
await this.save(0);
}
}
我面临的问题是,当在 describe() 中激活第二个 "it" 函数时,它会运行其中的所有函数,所以
clearEduTrain();edu();train()
全部被调用,没有 asyncron 命令。
同样出于某种原因,我在 clearEduTrain() 上遇到错误:
Should edit edu & training
- StaleElementReferenceError: stale element reference: element is not attached to the page document
(Session info: chrome=80.0.3987.87)
(Driver info: chromedriver=80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}),platform=Mac OS X 10.14.6 x86_64)
现在我仍然是量角器和 e2e 的菜鸟,你能解释一下发生了什么吗?
努力做到
async clearEduTrain() {
await browser.wait( // <--
// ...
我无法解决以下问题,也找不到任何相关信息,所以是时候 post 这里:
我有如下一段代码
const smdb = new SmdbPage;
const edit = new SmdbEdit;
describe('SMDB Edit:', () => {
it('should navigate to SMDB, select random',
async () => {
await smdb.navmenu(smdb.tooltipName.smbd);
await smdb.getFirst();
});
it('Should edit edu & training', async () => {
await edit.clearEduTrain();
await edit.edu();
await edit.train();
});
});
我有以下 class:
export class SmdbEdit extends BasicEdit {
EDUCATIONSANDTRAINING = element(by.testId('educationsTrainings'));
CVCOMMISSONBOX = element(by.testId('cvCommissionBox')).element(by.className('ibox-content'));
SKILLSBOX = element(by.testId('skills'));
// cv comission
VS = this.CVCOMMISSONBOX.element(by.testId('validationStatus')).all(by.className('ng-valid')).first();
cvSave = this.CVCOMMISSONBOX.element(by.testId('SaveBtn'));
CT = this.CVCOMMISSONBOX.element(by.testId('cvCommissionCampaignID'));
// Education
dateStart = this.EDUCATIONSANDTRAINING.element(by.testId('dateStart')).element(by.css('[autocorrect="off"]'));
dateEnd = this.EDUCATIONSANDTRAINING.element(by.testId('dateEnd')).element(by.css('[autocorrect="off"]'));
institution = this.EDUCATIONSANDTRAINING.element(by.testId('institution'));
qualifications = this.EDUCATIONSANDTRAINING.element(by.testId('qualification'));
eduTypeUntouched = this.EDUCATIONSANDTRAINING.element(by.testId('type'));
eduTypeTouched = this.eduTypeUntouched.element(by.css('[autocomplete="false"]'));
// Profession
yearSelect = this.EDUCATIONSANDTRAINING.element(by.testId('yearSelect'));
organisation = this.EDUCATIONSANDTRAINING.element(by.testId('organisation'));
training = this.EDUCATIONSANDTRAINING.element(by.testId('training'));
async clearEduTrain() {
browser.wait(
this.EC.urlContains('/smdb/edit/')
).then( async () => {
const arr: ElementArrayFinder = element.all(by.testId('deleteRow'));
arr.each( async (e: ElementFinder) => {
await browser.sleep(1000);
await e.mouseHoverClick();
});
});
}
async edu() {
await browser.sleep(1000);
await this.dateStart.sendKeys('2001-01-01');
await this.dateEnd.sendKeys('2002-01-01');
await this.qualifications.secureSendKeys('testQualification');
await this.institution.secureSendKeys('testInstitution');
await this.eduTypeUntouched.mouseHoverClick();
await this.eduTypeTouched.secureSendKeys(protractor.Key.ENTER);
await this.save(0);
}
async train() {
await this.yearSelect.mouseHoverClick();
await browser.sleep(1000);
await this.yearSelect.sendKeys(protractor.Key.ENTER);
await this.organisation.secureSendKeys('testOrg');
await this.organisation.secureSendKeys('testTraining');
await this.save(0);
}
}
我面临的问题是,当在 describe() 中激活第二个 "it" 函数时,它会运行其中的所有函数,所以
clearEduTrain();edu();train()
全部被调用,没有 asyncron 命令。
同样出于某种原因,我在 clearEduTrain() 上遇到错误:
Should edit edu & training
- StaleElementReferenceError: stale element reference: element is not attached to the page document
(Session info: chrome=80.0.3987.87)
(Driver info: chromedriver=80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}),platform=Mac OS X 10.14.6 x86_64)
现在我仍然是量角器和 e2e 的菜鸟,你能解释一下发生了什么吗?
努力做到
async clearEduTrain() {
await browser.wait( // <--
// ...