45
45
*/
46
46
public abstract class By {
47
47
/**
48
- * @param id The value of the "id" attribute to search for
49
- * @return a By which locates elements by the value of the "id" attribute.
48
+ * @param id The value of the "id" attribute to search for.
49
+ * @return A By which locates elements by the value of the "id" attribute.
50
50
*/
51
51
public static By id (final String id ) {
52
52
if (id == null )
53
53
throw new IllegalArgumentException (
54
- "Cannot find elements with a null id attribute ." );
54
+ "Cannot find elements when the id is null ." );
55
55
56
56
return new ById (id );
57
57
}
58
58
59
59
/**
60
- * @param linkText The exact text to match against
61
- * @return a By which locates A elements by the exact text it displays
60
+ * @param linkText The exact text to match against.
61
+ * @return A By which locates A elements by the exact text they display.
62
62
*/
63
63
public static By linkText (final String linkText ) {
64
64
if (linkText == null )
65
65
throw new IllegalArgumentException (
66
- "Cannot find elements when link text is null." );
66
+ "Cannot find elements when the link text is null." );
67
67
68
68
return new ByLinkText (linkText );
69
69
}
70
70
71
71
/**
72
- * @param linkText The text to match against
73
- * @return a By which locates A elements that contain the given link text
72
+ * @param linkText The text to match against.
73
+ * @return A By which locates A elements that contain the given text.
74
74
*/
75
75
public static By partialLinkText (final String linkText ) {
76
76
if (linkText == null )
77
77
throw new IllegalArgumentException (
78
- "Cannot find elements when link text is null." );
78
+ "Cannot find elements when the link text is null." );
79
79
80
80
return new ByPartialLinkText (linkText );
81
81
}
82
82
83
83
/**
84
- * @param name The value of the "name" attribute to search for
85
- * @return a By which locates elements by the value of the "name" attribute.
84
+ * @param name The value of the "name" attribute to search for.
85
+ * @return A By which locates elements by the value of the "name" attribute.
86
86
*/
87
87
public static By name (final String name ) {
88
88
if (name == null )
89
89
throw new IllegalArgumentException (
90
- "Cannot find elements when name text is null." );
90
+ "Cannot find elements when the name is null." );
91
91
92
92
return new ByName (name );
93
93
}
94
94
95
95
/**
96
- * @param name The element's tagName
97
- * @return a By which locates elements by their tag name
96
+ * @param name The element's tag name.
97
+ * @return A By which locates elements by their tag name.
98
98
*/
99
99
public static By tagName (final String name ) {
100
100
if (name == null )
101
101
throw new IllegalArgumentException (
102
- "Cannot find elements when name tag name is null." );
102
+ "Cannot find elements when the tag name is null." );
103
103
104
104
return new ByTagName (name );
105
105
}
106
106
107
107
/**
108
- * @param xpathExpression The xpath to use
109
- * @return a By which locates elements via XPath
108
+ * @param xpathExpression The XPath to use.
109
+ * @return A By which locates elements via XPath.
110
110
*/
111
111
public static By xpath (final String xpathExpression ) {
112
112
if (xpathExpression == null )
113
113
throw new IllegalArgumentException (
114
- "Cannot find elements when the XPath expression is null." );
114
+ "Cannot find elements when the XPath is null." );
115
115
116
116
return new ByXPath (xpathExpression );
117
117
}
118
118
119
119
/**
120
- * Finds elements based on the value of the "class" attribute. If an element has many classes then
121
- * this will match against each of them. For example if the value is "one two onone", then the
122
- * following "className"s will match: "one" and "two"
120
+ * Find elements based on the value of the "class" attribute. If an element has multiple classes, then
121
+ * this will match against each of them. For example, if the value is "one two onone", then the
122
+ * class names "one" and "two" will match.
123
123
*
124
- * @param className The value of the "class" attribute to search for
125
- * @return a By which locates elements by the value of the "class" attribute.
124
+ * @param className The value of the "class" attribute to search for.
125
+ * @return A By which locates elements by the value of the "class" attribute.
126
126
*/
127
127
public static By className (final String className ) {
128
128
if (className == null )
129
129
throw new IllegalArgumentException (
130
- "Cannot find elements when the class name expression is null." );
130
+ "Cannot find elements when the class name is null." );
131
131
132
132
return new ByClassName (className );
133
133
}
134
134
135
135
/**
136
- * Finds elements via the driver's underlying W3 Selector engine. If the browser does not
136
+ * Find elements via the driver's underlying W3 Selector engine. If the browser does not
137
137
* implement the Selector API, a best effort is made to emulate the API. In this case, we strive
138
138
* for at least CSS2 support, but offer no guarantees.
139
139
*
140
- * @param selector css expression
141
- * @return a By which locates elements by CSS.
140
+ * @param selector CSS expression.
141
+ * @return A By which locates elements by CSS.
142
142
*/
143
143
public static By cssSelector (final String selector ) {
144
144
if (selector == null )
145
145
throw new IllegalArgumentException (
146
- "Cannot find elements when the selector is null" );
146
+ "Cannot find elements when the CSS selector is null. " );
147
147
148
148
return new ByCssSelector (selector );
149
149
@@ -152,8 +152,8 @@ public static By cssSelector(final String selector) {
152
152
/**
153
153
* Find a single element. Override this method if necessary.
154
154
*
155
- * @param context A context to use to find the element
156
- * @return The WebElement that matches the selector
155
+ * @param context A context to use to find the element.
156
+ * @return The WebElement that matches the selector.
157
157
*/
158
158
public WebElement findElement (SearchContext context ) {
159
159
List <WebElement > allElements = findElements (context );
@@ -166,8 +166,8 @@ public WebElement findElement(SearchContext context) {
166
166
/**
167
167
* Find many elements.
168
168
*
169
- * @param context A context to use to find the element
170
- * @return A list of WebElements matching the selector
169
+ * @param context A context to use to find the elements.
170
+ * @return A list of WebElements matching the selector.
171
171
*/
172
172
public abstract List <WebElement > findElements (SearchContext context );
173
173
@@ -394,7 +394,7 @@ public WebElement findElement(SearchContext context) {
394
394
}
395
395
396
396
/**
397
- * Generates a partial xpath expression that matches an element whose specified attribute
397
+ * Generate a partial XPath expression that matches an element whose specified attribute
398
398
* contains the given CSS word. So to match <div class='foo bar'> you would say "//div[" +
399
399
* containingWord("class", "foo") + "]".
400
400
*
0 commit comments