用于网页警报的java Eventlistener
我需要知道网页上是否出现了特定的警报。我在swingworker中使用无限循环,类似这样:
try{
WebElement container = driver.findElement(By.cssSelector("#alert > a"));
String gifAlert = container.getCssValue("background-image");
if(gifAlert.equals(alert){
//Do something
}
}catch(//Stuff){
//Stuff
}
是否可以使用eventlistener来连续获取WebElement容器,并连续检查它是否与alert匹配,而不是使用swingworker和无限循环中的代码
# 1 楼答案
我不太了解硒,但在谷歌上搜索is possible to find the info that you may need
然而,一般的策略是,在截获事件后,不要将侦听器附加到元素,而是过滤元素。所以这两个步骤是实现监听器
然后向司机登记