DefaultSelenium AddLocationStrategy Method WebDriver
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.

Namespace: Selenium
Assembly: ThoughtWorks.Selenium.Core (in ThoughtWorks.Selenium.Core.dll) Version: 2.35.0.0 (2.35.0.0)
Syntax

public void AddLocationStrategy(
	string strategyName,
	string functionDefinition
)

Parameters

strategyName
Type: OnlineSystem String
the name of the strategy to define; this should use only letters [a-zA-Z] with no spaces or other punctuation.
functionDefinition
Type: OnlineSystem String
a string defining the body of a function in JavaScript. For example:
return inDocument.getElementById(locator);

Implements

ISelenium AddLocationStrategy(String, String)
See Also