晚饭生锈了;
我有几个承诺,仍然需要在班级中访问以前的版本,我正在尝试以最优雅的方式做到这一点。我在使用webdriverJS,这里应该解释所有驱动程序...谢谢您的帮助!
class funManeger
async fillOutDForm ( ){
try{
let that = this;
await driver.findElement( this.elementKeys.D ).clear();
await driver.findElement( this.elementKeys.D ).sendKeys(this.search.D);
await driver.wait(
webdriver.until.elementLocated(
this.elementKeys.DDropDown
),2250, // timeOut
'Could not find item in DropDown Item' //error message on timeout
).then( async function ( this ){
try {
await driver.sleep( this.getRandomInt(7) * 100 );
await driver.findElement( this.elementKeys.DDropDown ).click();
} catch (error) {
console.log( 'error clicking on D DropDown', this.elementKeys.DDropDown, error );
}
});
}catch (error){
console.log('Error Filling out D', error );
}
}
答案 0 :(得分:0)
如果您使用的是async/await
,则不需要.then()
class funManeger {
async fillOutDForm() {
try {
let that = this;
await driver.findElement(that.elementKeys.D).clear();
await driver.findElement(that.elementKeys.D).sendKeys(that.search.D);
let dropdown = await driver.wait(
webdriver.until.elementLocated(
that.elementKeys.DDropDown
), 2250, // timeOut
'Could not find item in DropDown Item' //error message on timeout
);
try {
await driver.sleep(that.getRandomInt(7) * 100);
await driver.findElement(that.elementKeys.DDropDown).click();
} catch (error) {
console.log('error clicking on D DropDown', this.elementKeys.DDropDown, error);
}
}catch (e) {
console.log('Error Filling out D', error );
}
}
}