У меня есть проблема, которую я пытаюсь решить. Веб-сайт, который я тестирую, - это сайт на основе Angular 8.0. В потоке я создал пользователя и получил уведомление о том, что операция прошла успешно. Я хотел бы закрыть его / проверить его / получить текст. Однако я не могу знать, как решить эту проблему, так как я пытался:
WebDriver driver2 = WebDriverMgr.getDriver();
WebDriverWait wait = new WebDriverWait(driver2, 19);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver2.switchTo().alert();
alert.accept();
В упомянутом консуле оповещение не отображается
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for alert to be present (tried for 19 second(s) with 500 milliseconds interval)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'PC', ip: '10.9.6.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.support.events.EventFiringWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 78.0.3904.70, chrome: {chromedriverVersion: 77.0.3865.40 (f484704e052e0..., userDataDir: C:\Users\AppData\Local...}, goog:chromeOptions: {debuggerAddress: localhost:49997}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 97b996f519dc2d21ec5185e4880ddce1
Согласно Dev это код уведомления, поскольку онииспользуя работу кадра нг-зорро. (https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/components/notification/nz-notification.component.html)
<div class="ant-notification-notice ant-notification-notice-closable"
[ngStyle]="nzMessage.options?.nzStyle"
[ngClass]="nzMessage.options?.nzClass"
[@notificationMotion]="state"
(mouseenter)="onEnter()"
(mouseleave)="onLeave()">
<div *ngIf="!nzMessage.template" class="ant-notification-notice-content">
<div class="ant-notification-notice-content" [ngClass]="{ 'ant-notification-notice-with-icon': nzMessage.type !== 'blank' }">
<div [class.ant-notification-notice-with-icon]="nzMessage.type !== 'blank'">
<ng-container [ngSwitch]="nzMessage.type">
<i *ngSwitchCase="'success'" nz-icon nzType="check-circle" class="ant-notification-notice-icon ant-notification-notice-icon-success"></i>
<i *ngSwitchCase="'info'" nz-icon nzType="info-circle" class="ant-notification-notice-icon ant-notification-notice-icon-info"></i>
<i *ngSwitchCase="'warning'" nz-icon nzType="exclamation-circle" class="ant-notification-notice-icon ant-notification-notice-icon-warning"></i>
<i *ngSwitchCase="'error'" nz-icon nzType="close-circle" class="ant-notification-notice-icon ant-notification-notice-icon-error"></i>
</ng-container>
<div class="ant-notification-notice-message" [innerHTML]="nzMessage.title"></div>
<div class="ant-notification-notice-description" [innerHTML]="nzMessage.content"></div>
</div>
</div>
</div>
<ng-template
[ngIf]="nzMessage.template"
[ngTemplateOutlet]="nzMessage.template"
[ngTemplateOutletContext]="{ $implicit: this, data: nzMessage.options?.nzData }">
</ng-template>
<a tabindex="0" class="ant-notification-notice-close" (click)="close()">
<span class="ant-notification-notice-close-x">
<i nz-icon nzType="close" class="ant-notification-close-icon"></i>
</span>
</a>
</div>
Это то, что отображается на экране, что я хочу получить текст или закрыть. Однако я не могу прочитать или приблизиться к нему.