skd
unread,Aug 29, 2012, 12:42:43 PM8/29/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to seleniu...@googlegroups.com
I've search through the forums, but haven't found any issues that match the problem I'm seeing. My apologies if this has been answered before...
My AUT has a link for deleting an object from the page. When I click the link manually, a JavaScript confirm box displays with Ok/Cancel buttons, but when my test clicks the link, no popup is displayed and the object is deleted immediately!
JavaScript on the page:
<a href="javascript:deleteSample('17');">
<img title="Delete Sample" alt="Delete" src="images/delete.gif"/>
</a>
JavaScript from .js file:
function deleteSample(sampleId) {
var sampleName = $('sampleName_' + sampleId).value;
confirmDelete = confirm("Are you sure you want to delete sample '" + sampleName + "'?");
if (sampleId != null && confirmDelete == true) {
new Ajax.Request(window.location.href, {
parameters: {
requestingMethod: "sampleSelector.deleteSample",
datasetId: dataset,
deleteSample: "true",
sampleSelectorId: sampleId
},
onComplete: this.deleteStatus,
onException: function (request, exception) { throw(exception); }
});
messagePopup("Deleting sample '" + sampleName + "'... (This may take a few moments)", "MESSAGE");
}
}
Test code (which times out on the waitForAlert():
String deleteLocator = "//a[@href=\"javascript:deleteSample('"+sampleId+"');\"]";
WebElement link = driver.findElement(By.xpath(deleteLocator));
link.click();
waitForAlert(5, driver);
assertTrue(driver.switchTo().alert().getText().matches("^Are you sure you want to delete sample '"+sampleName+"'[\\s\\S]$"));
driver.switchTo().alert().accept();
I'm using Firefox 14.0.1 with Selenium 2 v2.25.0.
Any help resolving this would be greatly appreciated.