File tree Expand file tree Collapse file tree 1 file changed +10
-27
lines changed
src/test/java/ru/mystamps/web/tests/page Expand file tree Collapse file tree 1 file changed +10
-27
lines changed Original file line number Diff line number Diff line change @@ -199,45 +199,28 @@ protected String getTextOfElementByTagName(final String tagName) {
199
199
//
200
200
201
201
protected boolean elementWithIdExists (final String elementId ) {
202
- WebElement el = null ;
203
-
204
- try {
205
- el = getElementById (elementId );
206
- } catch (final NoSuchElementException ex ) {
207
- return false ;
208
- }
209
-
210
- return el != null ;
202
+ return getElement (By .id (elementId )) != null ;
211
203
}
212
204
213
205
protected boolean elementWithXPathExists (final String xpath ) {
214
- WebElement el = null ;
215
-
216
- try {
217
- el = getElementByXPath (xpath );
218
- } catch (final NoSuchElementException ex ) {
219
- return false ;
220
- }
221
-
222
- return el != null ;
206
+ return getElement (By .xpath (xpath )) != null ;
223
207
}
224
208
225
209
protected boolean elementWithTagNameExists (final String tagName ) {
226
- WebElement el = null ;
227
-
210
+ return getElement (By .tagName (tagName )) != null ;
211
+ }
212
+
213
+ protected WebElement getLinkByText (final String linkText ) {
228
214
try {
229
- el = getElementByTagName ( tagName );
215
+ return driver . findElement ( By . linkText ( linkText ) );
230
216
} catch (final NoSuchElementException ex ) {
231
- return false ;
217
+ return null ;
232
218
}
233
-
234
- return el != null ;
235
219
}
236
220
237
- protected WebElement getLinkByText ( final String linkText ) {
221
+ private WebElement getElement ( By byMethod ) {
238
222
try {
239
- return driver .findElement (By .linkText (linkText ));
240
-
223
+ return driver .findElement (byMethod );
241
224
} catch (final NoSuchElementException ex ) {
242
225
return null ;
243
226
}
You can’t perform that action at this time.
0 commit comments