如何在 selenium 中验证 notify.js 警报

How to verify notify.js alert in selenium

我想验证通知消息的文本,其代码如下:

<div class="notifyjs-corner" style="top: 0px; left: 45%;">
  <div class="notifyjs-wrapper notifyjs-hidable">
    <div class="notifyjs-arrow" style=""/>
      <div class="notifyjs-container" style="">
        <div class="notifyjs-bootstrap-base notifyjs-bootstrap-success">
          <span data-notify-text="">Payment Created Successfully</span>
        </div>
    </div>
  </div>
</div>

我的硒代码是:

String notify = BrowserSetup
  .driver
  .findElement(By.xpath("//span[contains(.,
    'Payment Created Successfully')]"))
  .getText();
System.out.println(notify);

String notify 中的值为空。

问题

如何获取通知文本?

供参考:notify.js

Css Selector

查找元素
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".notifyjs-bootstrap-base.notifyjs-bootstrap-success>span"))).getText();

        String notify= BrowserSetup.driver.findElement(By.cssSelector(".notifyjs-bootstrap-base.notifyjs-bootstrap-success>span")).getText();
        System.out.println(notify);

当我 find element by cssSelector

它正在工作