1717@ SuppressWarnings ("unused" )
1818public class DriverHelper {
1919
20- // @Bean
21- // public DriverHelper driverHelper(){
22- // return new DriverHelper();
23- // }
24-
2520 private final Logger logger = LoggerFactory .getLogger (DriverHelper .class );
2621 private DriverManager driverManager ;
2722 @ Autowired
@@ -32,7 +27,7 @@ public class DriverHelper {
3227 */
3328 public void sendKeys (WebElement element , String value ) {
3429 if (value != null ) {
35- if (value .length () > 0 ) {
30+ if (! value .isEmpty () ) {
3631 clear (element );
3732 element .sendKeys (value );
3833 } else {
@@ -44,7 +39,7 @@ public void sendKeys(WebElement element, String value) {
4439 /**
4540 * Clicks on an element by WebElement
4641 */
47- @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), include = {RetryException .class })
42+ @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), retryFor = {RetryException .class })
4843 public void click (WebElement element ) throws NoSuchFieldException {
4944 try {
5045 driverWait .waitForElementToLoad (element );
@@ -58,7 +53,7 @@ public void click(WebElement element) throws NoSuchFieldException {
5853 /**
5954 * Clicks on an element by Locator
6055 */
61- @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), include = {RetryException .class })
56+ @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), retryFor = {RetryException .class })
6257 public void click (By locator ) throws NoSuchFieldException {
6358 try {
6459 driverWait .waitForElementToLoad (locator );
@@ -72,7 +67,7 @@ public void click(By locator) throws NoSuchFieldException {
7267 /**
7368 * Clicks on an element by Locator
7469 */
75- @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), include = {RetryException .class })
70+ @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), retryFor = { RetryException .class })
7671 public void rightClick (By locator ) throws NoSuchFieldException {
7772 driverWait .waitForElementToLoad (locator );
7873 final WebElement element = driverManager .getDriver ().findElement (locator );
@@ -81,25 +76,25 @@ public void rightClick(By locator) throws NoSuchFieldException {
8176 builder .moveToElement (element ).contextClick (element );
8277 builder .perform ();
8378 } catch (Exception ser ) {
84- logger .warn ("Could not click on the element : " + element );
79+ logger .warn ("Could not right click on the element : " + element );
8580 throw new RetryException ("Could not click on the element : " + element );
8681 }
8782 }
8883
89- @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), include = {RetryException .class })
84+ @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), retryFor = {RetryException .class })
9085 public void scrollElementIntoView (WebElement element ) {
9186 try {
9287 driverManager .getJSExecutor ().executeScript ("arguments[0].scrollIntoView(true);" , element );
9388 } catch (Exception ignored ) {
94- logger .warn ("Could not click on the element : " + element );
89+ logger .warn ("Could not scroll the element into view " + element );
9590 throw new RetryException ("Could not click on the element : " + element );
9691 }
9792 }
9893
9994 /**
10095 * Clicks on an element by WebElement
10196 */
102- @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), include = {RetryException .class })
97+ @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), retryFor = {RetryException .class })
10398 public void rightClick (WebElement element ) throws NoSuchFieldException {
10499 driverWait .waitForElementToLoad (element );
105100
@@ -117,23 +112,23 @@ public void rightClick(WebElement element) throws NoSuchFieldException {
117112 * Clicks on an element using Actions
118113 */
119114
120- @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), include = {RetryException .class })
115+ @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), retryFor = {RetryException .class })
121116 public void clickAction (WebElement element ) throws NoSuchFieldException {
122117 driverWait .waitForElementToLoad (element );
123118 try {
124119 final Actions builder = new Actions (driverManager .getDriver ());
125120 builder .moveToElement (element ).click (element );
126121 builder .perform ();
127122 } catch (Exception ser ) {
128- logger .warn ("Could not click on the element" );
123+ logger .warn ("Could not click action on the element" );
129124 throw new RetryException ("Could not click on the element : " + element );
130125 }
131126 }
132127
133128 /**
134129 * Clicks on an element using Actions
135130 */
136- @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), include = {RetryException .class })
131+ @ Retryable (maxAttempts = 3 , backoff = @ Backoff (delay = 500 ), retryFor = {RetryException .class })
137132 public void clickAction (By locator ) throws NoSuchFieldException {
138133 driverWait .waitForElementToLoad (locator );
139134
@@ -143,7 +138,7 @@ public void clickAction(By locator) throws NoSuchFieldException {
143138 builder .moveToElement (element ).click (element );
144139 builder .perform ();
145140 } catch (Exception ser ) {
146- logger .warn ("Could not click on the element" );
141+ logger .warn ("Could not click action on the element" );
147142 throw new RetryException ("Could not click on the element : " + element );
148143 }
149144 }
0 commit comments