Closed GoogleCodeExporter closed 9 years ago
addLocationStrategy ( strategyName,functionDefinition )
Defines a new function for Selenium to locate elements on the page. For example,
if you define the strategy "foo", and someone runs click("foo=blah"), we'll run
your
function, passing you the string "blah", and click on the element that your
function
returns, or throw an "Element not found" error if your function returns null.
We'll
pass three arguments to your function:
* locator: the string the user passed in
* inWindow: the currently selected window
* inDocument: the currently selected document
The function must return null if the element can't be found.
Arguments:
* strategyName - the name of the strategy to define; this should use only
letters [a-zA-Z] with no spaces or other punctuation.
* functionDefinition - a string defining the body of a function in
JavaScript. For example: return inDocument.getElementById(locator);
Original comment by John.Jian.Fang@gmail.com
on 6 Apr 2009 at 8:37
//MK: add the jquery location strategy
sel.addLocationStrategy("jquery", '''
var found = $(inDocument).find(locator);
if(found.length == 1){
//for now only support of selecting 1 element.
return found[0];
} else {
return null;
}
''')
sel.addLocationStrategy("jqueryall", '''
var found = $(inDocument).find(locator);
if(found.length > 0){
return found;
} else {
return null;
}
''')
Original comment by John.Jian.Fang@gmail.com
on 6 Apr 2009 at 8:47
Need to support css, for example,
$("#main > *").css("border", "3px double red");
Original comment by John.Jian.Fang@gmail.com
on 10 Apr 2009 at 4:22
Original comment by John.Jian.Fang@gmail.com
on 12 Apr 2009 at 6:19
Original issue reported on code.google.com by
John.Jian.Fang@gmail.com
on 9 Mar 2009 at 4:01