-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added exception wait time out to handle tolerant methods * applied the changes as mentioned in the review comments for tolerant methods * Changed the method to package private to not expose this method * Added test to validate the tolerant method without passing wait time for method * changed the variable names for the TolerantAction object as mentioned * futureDataAvoidingWeekendsAndBankHolidays issue which need to avoid weekends when adding bank holidays count * added overload method for tolerantItemByIndex and tolerantItemByHtmlValueAttribute * resolved conflicts * changed from private package to public * Changed onException method to take screenshot only on Local run not on running on grid * Changed onException method to take screenshot only on Local run not on running on grid * Added boolean parameter in config file to handle taking snapshots * 1.Created tolerant methods for clear,getAttribute,getText and isDisplayed methods. 2. Modified interact methods to handle tolerant methods. * 1.Created tolerant methods for clear,getAttribute and getText methods to handle required exceptions Co-authored-by: balavengaiah.matam <balavengaiah.matam@dwp.gov.uk>
- Loading branch information
Showing
4 changed files
with
254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package uk.co.evoco.webdriver.utils; | ||
|
||
import com.codahale.metrics.Timer; | ||
import org.openqa.selenium.WebElement; | ||
import uk.co.evoco.metrics.MetricRegistryHelper; | ||
import uk.co.evoco.webdriver.configuration.TestConfigHelper; | ||
|
||
import static com.codahale.metrics.MetricRegistry.name; | ||
|
||
public class ClearUtils extends TolerantInteraction { | ||
private static final Timer tolerantClearAction = MetricRegistryHelper.get().timer(name("ClearUtils.tolerantClear")); | ||
|
||
/** | ||
* | ||
* @param webElement active WebElement, already located | ||
* @param timeout time in seconds to keep trying | ||
* @throws Throwable any unhandled or un-tolerated exception | ||
*/ | ||
public static void tolerantClear(WebElement webElement, int timeout) throws Throwable { | ||
try(final Timer.Context ignored = tolerantClearAction.time()) { | ||
new ClearUtils().tolerantInteractionToClear(webElement, timeout); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param webElement active WebElement, already located | ||
* @throws Throwable any unhandled or un-tolerated exception | ||
*/ | ||
public static void tolerantClear(WebElement webElement) throws Throwable { | ||
try(final Timer.Context ignored = tolerantClearAction.time()) { | ||
new ClearUtils().tolerantInteractionToClear(webElement, | ||
TestConfigHelper.get().getTolerantActionWaitTimeoutInSeconds()); | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/uk/co/evoco/webdriver/utils/GetAttributeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package uk.co.evoco.webdriver.utils; | ||
|
||
import com.codahale.metrics.Timer; | ||
import org.openqa.selenium.WebElement; | ||
import uk.co.evoco.metrics.MetricRegistryHelper; | ||
import uk.co.evoco.webdriver.configuration.TestConfigHelper; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.codahale.metrics.MetricRegistry.name; | ||
|
||
public class GetAttributeUtils extends TolerantInteraction { | ||
private static final Timer tolerantGetAttributeAction = MetricRegistryHelper.get().timer(name("GetAttributeUtils.tolerantGetAttribute")); | ||
|
||
/** | ||
* | ||
* @param webElement active WebElement, already located | ||
* @param attribute WebElement attribute | ||
* @param timeout time in seconds to keep trying | ||
* @return attribute property value | ||
* @throws Throwable any unhandled or un-tolerated exception | ||
*/ | ||
public static String tolerantGetAttribute(WebElement webElement, String attribute, int timeout) throws Throwable { | ||
try (final Timer.Context ignored = tolerantGetAttributeAction.time()) { | ||
return new GetAttributeUtils().tolerantInteractionToGetAttribute(webElement,attribute,timeout); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param webElement active WebElement, already located | ||
* @param attribute WebElement attribute | ||
* @return attribute property value | ||
* @throws Throwable any unhandled or un-tolerated exception | ||
*/ | ||
public static String tolerantGetAttribute(WebElement webElement, String attribute) throws Throwable { | ||
try (final Timer.Context ignored = tolerantGetAttributeAction.time()) { | ||
return new GetAttributeUtils().tolerantInteractionToGetAttribute(webElement,attribute, | ||
TestConfigHelper.get().getTolerantActionWaitTimeoutInSeconds()); | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/uk/co/evoco/webdriver/utils/GetTextUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package uk.co.evoco.webdriver.utils; | ||
|
||
import com.codahale.metrics.Timer; | ||
import org.openqa.selenium.WebElement; | ||
import uk.co.evoco.metrics.MetricRegistryHelper; | ||
import uk.co.evoco.webdriver.configuration.TestConfigHelper; | ||
|
||
import static com.codahale.metrics.MetricRegistry.name; | ||
|
||
public class GetTextUtils extends TolerantInteraction { | ||
private static final Timer tolerantGetTextAction = MetricRegistryHelper.get().timer(name("GetTextUtils.tolerantGetText")); | ||
|
||
/** | ||
* | ||
* @param webElement active WebElement, already located | ||
* @param timeout time in seconds to keep trying | ||
* @return text property value | ||
* @throws Throwable any unhandled or un-tolerated exception | ||
*/ | ||
public static String tolerantGetText(WebElement webElement, int timeout) throws Throwable { | ||
try (final Timer.Context ignored = tolerantGetTextAction.time()) { | ||
return new GetTextUtils().tolerantInteractionToGetText(webElement,timeout); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param webElement active WebElement, already located | ||
* @return text property value | ||
* @throws Throwable any unhandled or un-tolerated exception | ||
*/ | ||
|
||
public static String tolerantGetText(WebElement webElement) throws Throwable { | ||
try (final Timer.Context ignored = tolerantGetTextAction.time()) { | ||
return new GetTextUtils().tolerantInteractionToGetText(webElement, | ||
TestConfigHelper.get().getTolerantActionWaitTimeoutInSeconds()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters