com.ibm.team.fvt.tests.utils
Class ByUtils

java.lang.Object
  extended by com.ibm.team.fvt.tests.utils.ByUtils

public class ByUtils
extends java.lang.Object

Utility class to create By locator mechanism.


Field Summary
static int CONTAINS_PATTERN
           
static int ENDS_WITH_PATTERN
           
static int EQUALS_PATTERN
          Comparison pattern value.
static int STARTS_WITH_PATTERN
           
 
Constructor Summary
ByUtils()
           
 
Method Summary
static java.lang.String xpathCompareWithText(int pattern, java.lang.String text, boolean item)
          Add to the given xpath builder a comparison to the given text following the given pattern.
static org.openqa.selenium.By xpathMatchingItemText(java.lang.String xpathPrefix, int pattern, java.lang.String text)
          Return a xpath to match the given text using the given pattern.
static org.openqa.selenium.By xpathMatchingItemText(java.lang.String xpathPrefix, java.lang.String text)
          Return a xpath to match the given text using the given pattern.
static org.openqa.selenium.By xpathMatchingText(int pattern, java.lang.String text)
          Return a xpath to match the given text using the given pattern.
static org.openqa.selenium.By xpathMatchingTexts(int pattern, boolean all, java.lang.String... texts)
          Return a xpath to match the given texts using the given pattern.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS_PATTERN

public static final int EQUALS_PATTERN
Comparison pattern value.

The patterns are bitwise, hence they can be combined. In that case, an OR applies with all the specified patterns.

For example, if you wan to compare either equals or starts-with, then use:
EQUALS_PATTERN | STARTS_WITH_PATTERN

See Also:
Constant Field Values

STARTS_WITH_PATTERN

public static final int STARTS_WITH_PATTERN
See Also:
Constant Field Values

ENDS_WITH_PATTERN

public static final int ENDS_WITH_PATTERN
See Also:
Constant Field Values

CONTAINS_PATTERN

public static final int CONTAINS_PATTERN
See Also:
Constant Field Values
Constructor Detail

ByUtils

public ByUtils()
Method Detail

xpathCompareWithText

public static java.lang.String xpathCompareWithText(int pattern,
                                                    java.lang.String text,
                                                    boolean item)
Add to the given xpath builder a comparison to the given text following the given pattern.

Parameters:
pattern - The pattern used for matching text. Currently supported are: WARNING: These bits cannot be combined for this method.
text - The text to compare with
item - Tells whether the text comparison concerns item or not

xpathMatchingItemText

public static org.openqa.selenium.By xpathMatchingItemText(java.lang.String xpathPrefix,
                                                           int pattern,
                                                           java.lang.String text)
Return a xpath to match the given text using the given pattern.

Parameters:
pattern - The pattern used for matching text. Currently supported are: WARNING: These bits cannot be combined for this method.
text - The text to match
Returns:
The xpath as a By.

xpathMatchingItemText

public static org.openqa.selenium.By xpathMatchingItemText(java.lang.String xpathPrefix,
                                                           java.lang.String text)
Return a xpath to match the given text using the given pattern.

Parameters:
text - The text to match
Returns:
The xpath as a By.

xpathMatchingText

public static org.openqa.selenium.By xpathMatchingText(int pattern,
                                                       java.lang.String text)
Return a xpath to match the given text using the given pattern.

Parameters:
pattern - The pattern used for matching text. Currently supported are: WARNING: These bits cannot be combined for this method.
text - The text to match
Returns:
The xpath as a By.

xpathMatchingTexts

public static org.openqa.selenium.By xpathMatchingTexts(int pattern,
                                                        boolean all,
                                                        java.lang.String... texts)
Return a xpath to match the given texts using the given pattern.

Note that if there are several texts provided, one can specify whether all of them must match or only one is enough.

Parameters:
pattern - The pattern used for matching text. Currently supported are: WARNING: These bits cannot be combined for this method.
all - Tells whether all texts must match or only one is enough. Ignored if only one text is given.
texts - The list of texts to match
Returns:
The xpath as a By.