【发布时间】:2016-09-02 08:37:07
【问题描述】:
我想验证通知消息的文本,代码如下:
<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
【问题讨论】:
-
尝试一次:
BrowserSetup.driver.findElement(By.cssSelector("div.notifyjs-bootstrap-base.notifyjs-bootstrap-success")).getText();并告诉我..:) -
它没有抛出这样的元素异常
-
您能告诉我此警报何时可见吗??
-
其实在弹窗关闭后可见。
-
那么你需要实现
WebDriverWait等到这个元素显示为new WebDriverWait(BrowserSetup.driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div.notifyjs-bootstrap-base.notifyjs-bootstrap-success"))).getText();并让我知道..
标签: javascript java selenium notifications gettext