Мне нужно выбрать следующую доступную кнопку в диалоговом окне, успех или неудача
Ниже приведен мой код, он выдает элемент успеха не найден, но не идет к оператору else для проверки другого элемента
async clickFailureSnackBarOKButton() {
try {
let button = await element( by.cssContainingText( 'some_id', 'OK' ) );
await browser.wait( until.visibilityOf( button ), this.DEFAULT_WAIT_TIME_SECONDS * 1000, 'failed to load OK button in the snack bar' );
await browser.executeScript( "arguments[0].click();", await button.getWebElement() );
return true;
}catch (e) {
return false;
}
}
async verifySuccessDialog(){
let dialog = await element( by.cssContainingText( 'Some_id','Success' ));
await browser.wait(until.elementToBeClickable(dialog), this.DEFAULT_WAIT_TIME_SECONDS * 1000, 'Success Dialog box did not appear.');
await expect(await (dialog).isPresent()).toBeTruthy('Dialog box is not actually present.');
browser.sleep(2000);
await this.clickOKButton();
}
async clickOKButton(){
let button = await element( by.buttonText( 'OK' ));
await browser.wait(until.elementToBeClickable(button), this.DEFAULT_WAIT_TIME_SECONDS * 1000, 'failed to load OK button');
await button.click();
}
async clickResultantButton(){
let dialog = await element( by.cssContainingText( 'some_id','Success' )).isDisplayed();
if(dialog){
try{
await this.verifySuccessDialog();
}catch (e) {
this.logger.error('Error message: ' + e);
}
} else {
try{
await this.clickFailureSnackBarOKButton();
}catch (e) {
this.logger.error('Error message: ' + e);
}
}
}