History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SEL-237
Type: New Feature New Feature
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Dan Fabulich
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Selenium

Add commands to set/get the cursor position and/or selection range/text

Created: 22/May/06 01:04 AM   Updated: 05/Feb/08 04:37 PM
Component/s: None
Affects Version/s: 0.7.0
Fix Version/s: 0.7.1


 Description  « Hide
This will be needed to fix SRC-55.

Detecting the cursor location is easy in Firefox, but it seems to be especially tricky in IE6; it's actually causing the Dojo code to break in Selenium because we're not specifying the cursor location, which we probably should.

Here's some sample code for IE:
http://the-stickman.com/web-development/javascript/finding-selection-cursor-position-in-a-textarea-in-internet-explorer/

Here's the code from Dojo's "dojo.widget.html.ComboBox" (which breaks in IE6 when there is no cursor in position):

getCaretPos: function(element){
// FIXME: we need to figure this out for Konq/Safari!
if(dojo.render.html.mozilla){ // FIXME: this is totally borked on Moz < 1.3. Any recourse? return element.selectionStart; }else if(dojo.render.html.ie){
// in the case of a mouse click in a popup being handled,
// then the document.selection is not the textarea, but the popup
// var r = document.selection.createRange();
// hack to get IE 6 to play nice. What a POS browser.
// var tr = r.duplicate();
var tr = document.selection.createRange().duplicate();
// var ntr = document.selection.createRange().duplicate();
var ntr = element.createTextRange();
// FIXME: this seems to work but I'm getting some execptions on reverse-tab
tr.move("character",0);
ntr.move("character",0);
/*
try{ ntr.moveToElementText(element); }catch(e){ dojo.debug(e); }
*/
ntr.setEndPoint("EndToEnd", tr);
return String(ntr.text).replace(/\r/g,"").length;
}
}

setting the cursor location seems to be a bit more straightforward:

http://www.faqts.com/knowledge_base/view.phtml/aid/15728



 All   Comments   Change History      Sort Order:
There are no comments yet on this issue.