public void testSuccess() throws InterruptedException {
System.out.println("test arribute popup");
Thread.sleep(3000);
WebElement searchBtn = driver.findElement(By.xpath(".//*[@id='investedList']/span/span[2]/span"));
Actions action = new Actions(driver);
action.moveToElement(searchBtn).perform();
Thread.sleep(3000);
}
当鼠标移动到按钮时,弹出文本显示为"投资列表" 如何使用selenium进行测试
答案 0 :(得分:0)
试试这段代码:
function notify(title, msg, url, img, name, isClickable) {
var listener = {
observe: function(subject, topic, data) { // jshint ignore:line
// if (topic === 'alertclickcallback') {
// }
// if (topic === 'alertfinished') {
// }
},
};
try {
var alertWin = Cc['@mozilla.org/alerts-service;1'].getService(Ci.nsIAlertsService);
alertWin.showAlertNotification(img, title, msg, isClickable, url, listener, name);
}
catch (e) {
// fix for when alerts-service is not available (e.g. SUSE)
var ALERT_XUL = 'chrome://global/content/alerts/alert.xul';
var FF_WIN_OPTS = 'chrome,dialog=yes,titlebar=no,popup=yes';
// arguments[0] --> the image src url
// arguments[1] --> the alert title
// arguments[2] --> the alert text
// arguments[3] --> is the text clickable?
// arguments[4] --> the alert cookie to be passed back to the listener
// arguments[5] --> the alert origin reported by the look and feel
// 0: bottom right.
// 2: bottom left
// 4: top right
// 6: top left
// arguments[6] --> bidi
// arguments[7] --> lang
// arguments[8] --> replaced alert window (nsIDOMWindow)
// // i. e. previous alert
// arguments[9] --> an optional callback listener (nsIObserver)
// arguments[10] -> the nsIURI.hostPort of the origin, optional
var winArgs = [img, title, msg, isClickable, url, 2, null, null, null, listener, name];
// aParentwindow, aUrl, aWindowName, aWindowFeatures, aWindowArguments (nsISupports)
var win = Services.ww.openWindow(null, ALERT_XUL, '_blank', FF_WIN_OPTS, null);
win.arguments = winArgs;
}
}
你可以使用ur html代码中的其他按钮属性,因为我不知道你的html代码中有哪种属性。 像这样:
List<WebElement> overlaysTooltips = driver.findElements(By.xpath(".//*[@id='investedList']/span/span[2]/span"));
for(int i = 0; i < overlaysTooltips.size(); i++){
Actions builder = new Actions(driver);
builder.moveToElement(overlaysTooltips.get(i)).perform();
//get button text after hover
if((overlaysTooltips.get(i).getAttribute("value").equals("//ur button hover string")){
//ur condition
Thread.sleep(3000);
}
}