|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.specrunner.parameters.core.ParameterHolder
org.specrunner.webdriver.impl.FinderXPath
public class FinderXPath
Utility class to manage search strategies to be used by browser aware plugins. You can register XPath search strategies, and reuse then in your tests. Patterns like search by id, name, value, a tag which contains something, tags or attributes that start with something, or pure XPath are already registered.
| Field Summary | |
|---|---|
protected String |
by
The reference to document objects. |
protected String |
separator
The separator of arguments in 'by' attribute. |
| Constructor Summary | |
|---|---|
protected |
FinderXPath()
Minimum constructor. |
| Method Summary | |
|---|---|
void |
addStrategy(String name,
String xpath)
Map an new search strategy. |
List<org.openqa.selenium.WebElement> |
find(IContext context,
IResultSet result,
org.openqa.selenium.WebDriver client)
Returns a list of elements. |
String |
findStrategy(String name)
Recover a given strategy. |
static FinderXPath |
get()
Gets the thread safe instance of finder. |
String[] |
getArguments(IContext context)
Get the arguments for search strategy. |
String |
getBy()
The search strategy to be used. i.e. |
String |
getSeparator()
Gets the parameter separator. |
Iterator<String> |
getStrategies()
List of available strategies. |
String |
getType()
Get the type of search strategy. i.e. |
String |
getXPath(IContext context)
Gets the XPath related to the plugin. |
void |
reset()
Clear any previous finder settings. |
String |
resume(IContext context)
The representation of the filter. |
void |
setBy(String by)
Sets the target reference. |
void |
setSeparator(String separator)
Sets the separator. |
| Methods inherited from class org.specrunner.parameters.core.ParameterHolder |
|---|
getParameters, setParameters |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.specrunner.parameters.IParameterHolder |
|---|
getParameters, setParameters |
| Field Detail |
|---|
protected String by
protected String separator
| Constructor Detail |
|---|
protected FinderXPath()
| Method Detail |
|---|
public static FinderXPath get()
public Iterator<String> getStrategies()
public void addStrategy(String name,
String xpath)
name - The strategy name.xpath - The corresponding XPath with replace masks as ${0}, ${1}, and
so on.public String findStrategy(String name)
name - The strategy name.
public String getBy()
by="id:txtName" means
find the element whose 'id' is 'txtName'. The 'by' attribute is closely
related to FindeXPath strategy.
The 'id' type is associated in FindeXPath to the XPath "//*[@id='{0}']", is means that if you use 'by="id:txtName"', this plugin will lookup the 'id' corresponding XPath, tokenize the content after ':' using ';' as separator and replace '{...}' elements in order. To use another separator set 'separator' attribute.
In the previous example, 'by=id:txtName' becomes a XPath expression "//*[@id='txtName']".
public void setBy(String by)
by - The reference.public String getSeparator()
public void setSeparator(String separator)
separator - The separator.public String getType()
public String[] getArguments(IContext context)
by=contains:a;site', the arguments will be
{0}=a and {1}=site, the corresponding XPath
will be "//a[contains(.,'site')]";<span by="contains:a;">data<span>, the arguments
will be {0}=a and {1}=data, the corresponding
XPath will be "//a[contains(.,'data')]";<span by="contains:">a;data<span>, the arguments
will be {0}=a and {1}=data, the corresponding
XPath will be "//a[contains(.,'data')]";<span by="contains:" separator="|">a|data<span>,
the arguments will be {0}=a and {1}=data, the
corresponding XPath will be "//a[contains(.,'data')]";
context - The test context.
public String getXPath(IContext context)
throws PluginException
context - The test context.
PluginException - On XPath generation errors.public void reset()
IFinder
reset in interface IFinder
public List<org.openqa.selenium.WebElement> find(IContext context,
IResultSet result,
org.openqa.selenium.WebDriver client)
throws PluginException
IFinder
find in interface IFindercontext - The test context.result - The result set.client - The browser.
PluginException - On filter errors.
public String resume(IContext context)
throws PluginException
IFinder
resume in interface IFindercontext - The test context.
PluginException - On detail errors.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||