Run TestCusorPosition test in Opera 8. It will fail.
Now try replacing the refreshAndWait call with unselectText (described below). Instead of correctly reporting that there is no cursor, it incorrectly reports that the cursor exists at its previous location, which is definitely incorrect.
No obvious way to fix this; just adding a warning in the docs.
Description
Run TestCusorPosition test in Opera 8. It will fail.
Now try replacing the refreshAndWait call with unselectText (described below). Instead of correctly reporting that there is no cursor, it incorrectly reports that the cursor exists at its previous location, which is definitely incorrect.
No obvious way to fix this; just adding a warning in the docs.
Unselects any text that the user has selected.
*/
var win = this.browserbot.getCurrentWindow();
var doc = this.page().currentDocument;
if (doc.selection && doc.selection.empty) {
doc.selection.empty();
doc.selection.clear();
return;
} else if (win.getSelection && win.getSelection().removeAllRanges) {
win.getSelection().removeAllRanges();
return;
}
else if (doc.getSelection && doc.getSelection().removeAllRanges) {
doc.getSelection().removeAllRanges();
return;
}
throw new Error("Couldn't unselect text on this browser!");
}
Note that to add this into selenium and add a test for it, we'd have to add a function that can select text, which will be tricky in Selenese, because you'll have to supply three arguments: locator, start, and end.
Dan Fabulich - 24/May/06 02:40 PM Here's a command that will unselectText:
Selenium.prototype.doUnselectText = function() {
/**
Unselects any text that the user has selected.
*/
var win = this.browserbot.getCurrentWindow();
var doc = this.page().currentDocument;
if (doc.selection && doc.selection.empty) {
doc.selection.empty();
doc.selection.clear();
return;
} else if (win.getSelection && win.getSelection().removeAllRanges) {
win.getSelection().removeAllRanges();
return;
}
else if (doc.getSelection && doc.getSelection().removeAllRanges) {
doc.getSelection().removeAllRanges();
return;
}
throw new Error("Couldn't unselect text on this browser!");
}
Note that to add this into selenium and add a test for it, we'd have to add a function that can select text, which will be tricky in Selenese, because you'll have to supply three arguments: locator, start, and end.
I've changed this test so we don't actually use unselectText; we just do refreshAndWait instead. This still doesn't work correctly in Opera 8, but this may be fixed in Opera 9.
Dan Fabulich - 24/May/06 03:15 PM I've changed this test so we don't actually use unselectText; we just do refreshAndWait instead. This still doesn't work correctly in Opera 8, but this may be fixed in Opera 9.
Selenium.prototype.doUnselectText = function() {
/**
*/
var win = this.browserbot.getCurrentWindow();
var doc = this.page().currentDocument;
if (doc.selection && doc.selection.empty) { doc.selection.empty(); doc.selection.clear(); return; } else if (win.getSelection && win.getSelection().removeAllRanges) { win.getSelection().removeAllRanges(); return; }
else if (doc.getSelection && doc.getSelection().removeAllRanges) { doc.getSelection().removeAllRanges(); return; }
throw new Error("Couldn't unselect text on this browser!");
}
Note that to add this into selenium and add a test for it, we'd have to add a function that can select text, which will be tricky in Selenese, because you'll have to supply three arguments: locator, start, and end.