How to use ActionPoller class of com.qaprosoft.carina.core.foundation.retry package

Best Carina code snippet using com.qaprosoft.carina.core.foundation.retry.ActionPoller

Source:DriverHelper.java Github

copy

Full Screen

...68import org.slf4j.LoggerFactory;69import org.testng.Assert;70import com.qaprosoft.carina.core.foundation.commons.SpecialKeywords;71import com.qaprosoft.carina.core.foundation.crypto.CryptoTool;72import com.qaprosoft.carina.core.foundation.retry.ActionPoller;73import com.qaprosoft.carina.core.foundation.utils.Configuration;74import com.qaprosoft.carina.core.foundation.utils.Configuration.Parameter;75import com.qaprosoft.carina.core.foundation.utils.LogicUtils;76import com.qaprosoft.carina.core.foundation.utils.Messager;77import com.qaprosoft.carina.core.foundation.utils.common.CommonUtils;78import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;79import com.qaprosoft.carina.core.foundation.webdriver.listener.DriverListener;80import com.qaprosoft.carina.core.gui.AbstractPage;81/**82 * DriverHelper - WebDriver wrapper for logging and reporting features. Also it83 * contains some complex operations with UI.84 * 85 * @author Alex Khursevich86 */87public class DriverHelper {88 private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());89 protected static final long EXPLICIT_TIMEOUT = Configuration.getLong(Parameter.EXPLICIT_TIMEOUT);90 91 protected static final long SHORT_TIMEOUT = Configuration.getLong(Parameter.EXPLICIT_TIMEOUT) / 3;92 protected static final long RETRY_TIME = Configuration.getLong(Parameter.RETRY_INTERVAL);93 protected long timer;94 protected WebDriver driver;95 96 protected String pageURL = getUrl();97 protected CryptoTool cryptoTool;98 protected static Pattern CRYPTO_PATTERN = Pattern.compile(SpecialKeywords.CRYPT);99 public DriverHelper() {100 cryptoTool = new CryptoTool(Configuration.getCryptoParams());101 }102 public DriverHelper(WebDriver driver) {103 this();104 105 this.driver = driver;106 if (driver == null) {107 throw new RuntimeException("WebDriver not initialized, check log files for details!");108 }109 }110 111 /**112 * Opens page according to specified in constructor URL.113 */114 public void open() {115 openURL(this.pageURL);116 }117 118 /**119 * Open URL.120 * 121 * @param url122 * to open.123 */124 public void openURL(String url) {125 openURL(url, Configuration.getInt(Parameter.EXPLICIT_TIMEOUT));126 }127 128 /**129 * Open URL.130 * 131 * @param url132 * to open.133 * @param timeout134 * long135 */136 public void openURL(String url, long timeout) {137 final String decryptedURL = getEnvArgURL(cryptoTool.decryptByPattern(url, CRYPTO_PATTERN));138 this.pageURL = decryptedURL;139 WebDriver drv = getDriver();140 141 setPageLoadTimeout(drv, timeout);142 DriverListener.setMessages(Messager.OPENED_URL.getMessage(url), Messager.NOT_OPENED_URL.getMessage(url));143 144 // [VD] there is no sense to use fluent wait here as selenium just don't return something until page is ready!145 // explicitly limit time for the openURL operation146 try {147 Messager.OPENING_URL.info(url);148 drv.get(decryptedURL);149 } catch (UnhandledAlertException e) {150 drv.switchTo().alert().accept();151 } catch (TimeoutException e) {152 trigger("window.stop();"); //try to cancel page loading153 Assert.fail("Unable to open url during " + timeout + "sec!");154 } catch (Exception e) {155 Assert.fail("Undefined error on open url detected: " + e.getMessage(), e);156 } finally {157 //restore default pageLoadTimeout driver timeout158 setPageLoadTimeout(drv, getPageLoadTimeout());159 LOGGER.debug("finished driver.get call.");160 }161 }162 protected void setPageURL(String relURL) {163 String baseURL;164 // if(!"NULL".equalsIgnoreCase(Configuration.get(Parameter.ENV)))165 if (!Configuration.get(Parameter.ENV).isEmpty()) {166 baseURL = Configuration.getEnvArg("base");167 } else {168 baseURL = Configuration.get(Parameter.URL);169 }170 this.pageURL = baseURL + relURL;171 }172 protected void setPageAbsoluteURL(String url) {173 this.pageURL = url;174 }175 public String getPageURL() {176 return this.pageURL;177 } 178 // --------------------------------------------------------------------------179 // Base UI interaction operations180 // --------------------------------------------------------------------------181 /**182 * Method which quickly looks for all element and check that they present183 * during EXPLICIT_TIMEOUT184 *185 * @param elements186 * ExtendedWebElement...187 * @return boolean return true only if all elements present.188 */189 public boolean allElementsPresent(ExtendedWebElement... elements) {190 return allElementsPresent(EXPLICIT_TIMEOUT, elements);191 }192 /**193 * Method which quickly looks for all element and check that they present194 * during timeout sec195 *196 * @param timeout long197 * @param elements198 * ExtendedWebElement...199 * @return boolean return true only if all elements present.200 */201 public boolean allElementsPresent(long timeout, ExtendedWebElement... elements) {202 int index = 0;203 boolean present = true;204 boolean ret = true;205 int counts = 1;206 timeout = timeout / counts;207 if (timeout < 1)208 timeout = 1;209 while (present && index++ < counts) {210 for (int i = 0; i < elements.length; i++) {211 present = elements[i].isElementPresent(timeout);212 if (!present) {213 LOGGER.error(elements[i].getNameWithLocator() + " is not present.");214 ret = false;215 }216 }217 }218 return ret;219 }220 /**221 * Method which quickly looks for all element lists and check that they222 * contain at least one element during SHORT_TIMEOUT223 *224 * @param elements225 * List&lt;ExtendedWebElement&gt;...226 * @return boolean227 */228 @SuppressWarnings("unchecked")229 public boolean allElementListsAreNotEmpty(List<ExtendedWebElement>... elements) {230 return allElementListsAreNotEmpty(SHORT_TIMEOUT, elements);231 }232 /**233 * Method which quickly looks for all element lists and check that they234 * contain at least one element during timeout235 *236 * @param timeout long237 * @param elements238 * List&lt;ExtendedWebElement&gt;...239 * @return boolean return true only if All Element lists contain at least240 * one element241 */242 @SuppressWarnings("unchecked")243 public boolean allElementListsAreNotEmpty(long timeout, List<ExtendedWebElement>... elements) {244 boolean ret;245 int counts = 3;246 timeout = timeout / counts;247 if (timeout < 1)248 timeout = 1;249 for (int i = 0; i < elements.length; i++) {250 boolean present = false;251 int index = 0;252 while (!present && index++ < counts) {253 try {254 present = elements[i].get(0).isElementPresent(timeout);255 } catch (Exception e) {256 present = false;257 }258 }259 ret = (elements[i].size() > 0);260 if (!ret) {261 LOGGER.error("List of elements[" + i + "] from elements " + Arrays.toString(elements) + " is empty.");262 return false;263 }264 }265 return true;266 }267 /**268 * Method which quickly looks for any element presence during269 * SHORT_TIMEOUT270 *271 * @param elements ExtendedWebElement...272 * @return true if any of elements was found.273 */274 public boolean isAnyElementPresent(ExtendedWebElement... elements) {275 return isAnyElementPresent(SHORT_TIMEOUT, elements);276 }277 /**278 * Method which quickly looks for any element presence during timeout sec279 *280 * @param timeout long281 * @param elements282 * ExtendedWebElement...283 * @return true if any of elements was found.284 */285 public boolean isAnyElementPresent(long timeout, ExtendedWebElement... elements) {286 int index = 0;287 int counts = 10;288 timeout = timeout / counts;289 if (timeout < 1)290 timeout = 1;291 while (index++ < counts) {292 for (int i = 0; i < elements.length; i++) {293 if (elements[i].isElementPresent(timeout)) {294 LOGGER.debug(elements[i].getNameWithLocator() + " is present");295 return true;296 }297 }298 }299 300 LOGGER.error("Unable to find any element from array: " + Arrays.toString(elements));301 return false;302 }303 /**304 * return Any Present Element from the list which present during305 * SHORT_TIMEOUT306 *307 * @param elements ExtendedWebElement...308 * @return ExtendedWebElement309 */310 public ExtendedWebElement returnAnyPresentElement(ExtendedWebElement... elements) {311 return returnAnyPresentElement(SHORT_TIMEOUT, elements);312 }313 /**314 * return Any Present Element from the list which present during timeout sec315 *316 * @param timeout long317 * @param elements318 * ExtendedWebElement...319 * @return ExtendedWebElement320 */321 public ExtendedWebElement returnAnyPresentElement(long timeout, ExtendedWebElement... elements) {322 int index = 0;323 int counts = 10;324 timeout = timeout / counts;325 if (timeout < 1)326 timeout = 1;327 while (index++ < counts) {328 for (int i = 0; i < elements.length; i++) {329 if (elements[i].isElementPresent(timeout)) {330 LOGGER.debug(elements[i].getNameWithLocator() + " is present");331 return elements[i];332 }333 }334 }335 //throw exception anyway if nothing was returned inside for cycle336 LOGGER.error("All elements are not present");337 throw new RuntimeException("Unable to find any element from array: " + Arrays.toString(elements));338 }339 /**340 * Check that element with text present.341 * 342 * @param extWebElement to check if element with text is present343 * @param text344 * of element to check.345 * @return element with text existence status.346 */347 public boolean isElementWithTextPresent(final ExtendedWebElement extWebElement, final String text) {348 return isElementWithTextPresent(extWebElement, text, EXPLICIT_TIMEOUT);349 }350 /**351 * Check that element with text present.352 * 353 * @param extWebElement to check if element with text is present354 * @param text355 * of element to check.356 * @param timeout Long357 * @return element with text existence status.358 */359 public boolean isElementWithTextPresent(final ExtendedWebElement extWebElement, final String text, long timeout) {360 return extWebElement.isElementWithTextPresent(text, timeout);361 }362 /**363 * Check that element not present on page.364 * 365 * @param extWebElement to check if element is not present366 * 367 * @return element non-existence status.368 */369 public boolean isElementNotPresent(final ExtendedWebElement extWebElement) {370 return isElementNotPresent(extWebElement, EXPLICIT_TIMEOUT);371 }372 /**373 * Check that element not present on page.374 * 375 * @param extWebElement to check if element is not present376 * @param timeout to wait377 * 378 * @return element non-existence status.379 */380 public boolean isElementNotPresent(final ExtendedWebElement extWebElement, long timeout) {381 return extWebElement.isElementNotPresent(timeout);382 }383 /**384 * Check that element not present on page.385 * 386 * @param element to check if element is not present387 * @param controlInfo String388 * 389 * @return element non-existence status.390 */391 public boolean isElementNotPresent(String controlInfo, final WebElement element) {392 return isElementNotPresent(new ExtendedWebElement(element, controlInfo));393 }394 /**395 * Clicks on element.396 * 397 * @param elements ExtendedWebElements to click398 *399 */400 public void clickAny(ExtendedWebElement... elements) {401 clickAny(EXPLICIT_TIMEOUT, elements);402 }403 /**404 * Clicks on element.405 * 406 * @param elements ExtendedWebElements to click407 * @param timeout to wait408 *409 */410 public void clickAny(long timeout, ExtendedWebElement... elements) {411 // Method which quickly looks for any element and click during timeout412 // sec413 WebDriver drv = getDriver();414 ActionPoller<WebElement> actionPoller = ActionPoller.builder();415 Optional<WebElement> searchableElement = actionPoller.task(() -> {416 WebElement possiblyFoundElement = null;417 for (ExtendedWebElement element : elements) {418 List<WebElement> foundElements = drv.findElements(element.getBy());419 if (foundElements.size() > 0) {420 possiblyFoundElement = foundElements.get(0);421 break;422 }423 }424 return possiblyFoundElement;425 })426 .until(Objects::nonNull)427 .pollEvery(0, ChronoUnit.SECONDS)428 .stopAfter(timeout, ChronoUnit.SECONDS)...

Full Screen

Full Screen

Source:APIMethodPoller.java Github

copy

Full Screen

1package com.qaprosoft.carina.core.foundation.api;2import com.qaprosoft.carina.core.foundation.api.log.ConditionalLoggingOutputStream;3import com.qaprosoft.carina.core.foundation.retry.ActionPoller;4import io.restassured.response.Response;5import org.slf4j.Logger;6import org.slf4j.LoggerFactory;7import org.slf4j.event.Level;8import java.lang.invoke.MethodHandles;9import java.time.temporal.TemporalUnit;10import java.util.Optional;11import java.util.function.Consumer;12import java.util.function.Predicate;13public class APIMethodPoller {14 private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());15 private final ActionPoller<Response> actionPoller;16 private final AbstractApiMethodV2 method;17 private LogStrategy logStrategy;18 private Consumer<Response> afterExecuteAction;19 public enum LogStrategy {20 ALL, LAST_ONLY, NONE21 }22 private APIMethodPoller(AbstractApiMethodV2 method) {23 this.method = method;24 this.actionPoller = ActionPoller.builder();25 }26 public static APIMethodPoller builder(AbstractApiMethodV2 method) {27 return new APIMethodPoller(method);28 }29 /**30 * Sets the repetition interval for the api calling31 *32 * @param period repetition interval33 * @param timeUnit time unit34 * @return APIMethodPoller object35 */36 public APIMethodPoller pollEvery(long period, TemporalUnit timeUnit) {37 this.actionPoller.pollEvery(period, timeUnit);38 return this;...

Full Screen

Full Screen

Source:ActionPoller.java Github

copy

Full Screen

...10import java.util.function.Consumer;11import java.util.function.Predicate;12import java.util.function.Supplier;13import com.qaprosoft.carina.core.foundation.utils.common.CommonUtils;14public class ActionPoller<T> {15 private Duration timeout;16 private Duration pollingInterval;17 private Supplier<T> task;18 private Predicate<T> successCondition;19 private final List<Consumer<T>> peekActions;20 private ActionPoller() {21 this.timeout = Duration.ofSeconds(60);22 this.pollingInterval = Duration.ofSeconds(5);23 this.peekActions = new ArrayList<>();24 }25 public static <T> ActionPoller<T> builder() {26 return new ActionPoller<>();27 }28 /**29 * Sets the retry time of the task30 *31 * @param period repetition interval32 * @param timeUnit time unit33 * @return ActionPoller object34 */35 public ActionPoller<T> pollEvery(long period, TemporalUnit timeUnit) {36 this.pollingInterval = Duration.of(period, timeUnit);37 return this;38 }39 /**40 * Sets the timeout for the given task41 *42 * @param timeout timeout43 * @param timeUnit time unit44 * @return ActionPoller object45 */46 public ActionPoller<T> stopAfter(long timeout, TemporalUnit timeUnit) {47 this.timeout = Duration.of(timeout, timeUnit);48 return this;49 }50 /**51 * Adds an action that will be executed immediately after the task52 *53 * @param peekAction lambda expression54 * @return ActionPoller object55 */56 public ActionPoller<T> peek(Consumer<T> peekAction) {57 this.peekActions.add(peekAction);58 return this;59 }60 /**61 * Sets the task to repeat62 *63 * @param task lambda expression64 * @return ActionPoller object65 */66 public ActionPoller<T> task(Supplier<T> task) {67 this.task = task;68 return this;69 }70 /**71 * Sets the condition under which the task is considered successfully completed and the result is returned72 *73 * @param successCondition lambda expression that that should return true if we consider the task completed74 * successfully, and false if not75 * @return ActionPoller object76 */77 public ActionPoller<T> until(Predicate<T> successCondition) {78 this.successCondition = successCondition;79 return this;80 }81 /**82 * Starts a task repetition with a condition. if the condition is met, then the method returns result, otherwise, if83 * the time was elapsed, the method returns null84 *85 * @return result of the task method if condition successful, otherwise returns null86 */87 public Optional<T> execute() {88 validateParameters();89 AtomicBoolean stopExecution = setupTerminateTask();90 T result = null;91 while (!stopExecution.get()) {...

Full Screen

Full Screen

ActionPoller

Using AI Code Generation

copy

Full Screen

1import org.testng.Assert;2import org.testng.annotations.Test;3import com.qaprosoft.carina.core.foundation.retry.ActionPoller;4public class ActionPollerTest {5 public void testPoller() {6 ActionPoller.poller().perform(() -> {7 Assert.assertTrue(false);8 });9 }10}11import org.testng.Assert;12import org.testng.annotations.Test;13import com.qaprosoft.carina.core.foundation.utils.ActionPoller;14public class ActionPollerTest {15 public void testPoller() {16 ActionPoller.poller().perform(() -> {17 Assert.assertTrue(false);18 });19 }20}

Full Screen

Full Screen

ActionPoller

Using AI Code Generation

copy

Full Screen

1import org.testng.Assert;2import org.testng.annotations.Test;3import com.qaprosoft.carina.core.foundation.retry.ActionPoller;4import com.qaprosoft.carina.core.foundation.retry.RetryAnalyzer;5public class TestPoller {6public void testPoller() {7ActionPoller poller = new ActionPoller(100, 1000);8poller.setAction(() -> {9});10poller.setCondition(() -> {11return true;12});13poller.run();14}15}16import org.testng.Assert;17import org.testng.annotations.Test;18import com.qaprosoft.carina.core.foundation.retry.ActionPoller;19import com.qaprosoft.carina.core.foundation.retry.RetryAnalyzer;20public class TestPoller {21public void testPoller() {22ActionPoller poller = new ActionPoller(100, 1000);23poller.setAction(() -> {24});25poller.setCondition(() -> {26return true;27});28poller.run();29}30}31import org.testng.Assert;32import org.testng.annotations.Test;33import com.qaprosoft.carina.core.foundation.retry.ActionPoller;34import com.qaprosoft.carina.core.foundation.retry.RetryAnalyzer;35public class TestPoller {36public void testPoller() {37ActionPoller poller = new ActionPoller(100, 1000);38poller.setAction(() -> {39});40poller.setCondition(() -> {41return true;42});43poller.run();44}45}46import org.testng

Full Screen

Full Screen

ActionPoller

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.carina.core.foundation.retry.ActionPoller;2import org.testng.Assert;3import org.testng.annotations.Test;4public class ActionPollerTest {5public void testPoller() {6ActionPoller poller = new ActionPoller(10, 1000);7poller.doAction(new ActionPoller.IAction() {8public boolean doAction() {9System.out.println("Polling...");10return false;11}12});13}14}15import com.qaprosoft.carina.core.foundation.utils.ActionPoller;16import org.testng.Assert;17import org.testng.annotations.Test;18public class ActionPollerTest {19public void testPoller() {20ActionPoller poller = new ActionPoller(10, 1000);21poller.doAction(new ActionPoller.IAction() {22public boolean doAction() {23System.out.println("Polling...");24return false;25}26});27}28}29import com.qaprosoft.carina.core.foundation.utils.R;30import org.testng.Assert;31import org.testng.annotations.Test;32public class ActionPollerTest {33public void testPoller() {34ActionPoller poller = new ActionPoller(10, 1000);35poller.doAction(new ActionPoller.IAction() {36public boolean doAction() {37System.out.println("Polling...");38return false;39}40});41}42}43import com.qaprosoft.carina.core.foundation.utils.R;44import org.testng.Assert;45import org.testng.annotations.Test;46public class ActionPollerTest {47public void testPoller() {48ActionPoller poller = new ActionPoller(10, 1000);49poller.doAction(new ActionPoller.IAction() {50public boolean doAction() {51System.out.println("Polling...");52return false;53}54});55}56}57import com.qaprosoft.carina.core.foundation.utils.R;58import org.testng.Assert;59import org.testng.annotations.Test;

Full Screen

Full Screen

ActionPoller

Using AI Code Generation

copy

Full Screen

1package com.qaprosoft.carina.demo;2import org.testng.annotations.Test;3import com.qaprosoft.carina.core.foundation.retry.RetryAnalyzer;4import com.qaprosoft.carina.core.foundation.retry.RetryRule;5import com.qaprosoft.carina.core.foundation.retry.RetryType;6import com.qaprosoft.carina.core.foundation.utils.R;7import com.qaprosoft.carina.core.foundation.webdriver.decorator.ExtendedWebElement;8import com.qaprosoft.carina.core.foundation.webdriver.decorator.factory.ExtendedWebElementFactory;9import com.qaprosoft.carina.core.foundation.webdriver.listener.EventFiringWebDriver;10import com.qaprosoft.carina.core.foundation.webdriver.listener.impl.ActionPoller;11import com.qaprosoft.carina.core.foundation.webdriver.listener.impl.EventListener;12import com.qaprosoft.carina.core.gui.AbstractPage;13import com.qaprosoft.carina.core.gui.AbstractUIObject;14import com.qaprosoft.carina.core.gui.AbstractUIObject.Type;15import com.qaprosoft.carina.core.gui.AbstractUIObject.LocatorType;16import com.qaprosoft.carina.core.gui.AbstractUIObject.RetryAnalyzerType;17import com.qaprosoft.carina.core.gui.AbstractUIObject.RetryRuleType;18import com.qaprosoft.carina.core.gui.AbstractUIObject.RetryType;19@RetryRule(RetryRuleType.CUSTOM)20@RetryAnalyzer(RetryAnalyzerType.CUSTOM)21@RetryType(RetryType.CUSTOM)22public class RetryTest extends AbstractPage {23public RetryTest(EventFiringWebDriver driver) {24 super(driver);25}26@RetryRule(RetryRuleType.CUSTOM)27@RetryAnalyzer(RetryAnalyzerType.CUSTOM)28@RetryType(RetryType.CUSTOM)29public void test(){30 ExtendedWebElement element = ExtendedWebElementFactory.getExtendedWebElement(Type.BUTTON, "test", LocatorType.XPATH, driver);31 ActionPoller poller = new ActionPoller(driver, element);32 poller.poll();33}34}35package com.qaprosoft.carina.demo;36import org.testng.annotations.Test;37import com.qaprosoft.carina.core.foundation.retry.RetryAnalyzer;38import com.qaprosoft.carina.core.foundation.retry.RetryRule;39import com.qaprosoft.carina.core.foundation.retry.RetryType;

Full Screen

Full Screen

ActionPoller

Using AI Code Generation

copy

Full Screen

1import java.lang.reflect.Method;2import java.util.concurrent.TimeUnit;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.chrome.ChromeDriver;5import org.testng.annotations.AfterMethod;6import org.testng.annotations.BeforeMethod;7import org.testng.annotations.Test;8import com.qaprosoft.carina.core.foundation.retry.ActionPoller;9import com.qaprosoft.carina.core.foundation.retry.RetryType;10import com.qaprosoft.carina.core.foundation.retry.Retryer;11public class ActionPollerTest {12WebDriver driver;13public void beforeMethod(Method m) {14driver = new ChromeDriver();15driver.manage().window().maximize();16driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);17}18public void afterMethod(Method m) {19driver.quit();20}21public void testActionPoller() {22ActionPoller poller = new ActionPoller(RetryType.CUSTOM, 2, 1000);23poller.doAction(new Retryer() {24public boolean retryAction() {25return driver.getTitle().equals("Google");26}27});28}29}30import java.lang.reflect.Method;31import java.util.concurrent.TimeUnit;32import org.openqa.selenium.WebDriver;33import org.openqa.selenium.chrome.ChromeDriver;34import org.testng.annotations.AfterMethod;35import org.testng.annotations.BeforeMethod;36import org.testng.annotations.Test;37import com.qaprosoft.carina.core.foundation.retry.ActionPoller;38import com.qaprosoft.carina.core.foundation.retry.RetryType;39import com.qaprosoft.carina.core.foundation.retry.Retryer;40public class ActionPollerTest {41WebDriver driver;42public void beforeMethod(Method m) {43driver = new ChromeDriver();44driver.manage().window().maximize();45driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);46}47public void afterMethod(Method m) {48driver.quit();49}50public void testActionPoller() {51ActionPoller poller = new ActionPoller(RetryType.CUSTOM, 2, 1000);52poller.doAction(new Retryer() {53public boolean retryAction() {54return driver.getTitle().equals("Google");55}56});57}58}

Full Screen

Full Screen

ActionPoller

Using AI Code Generation

copy

Full Screen

1ActionPoller poller = new ActionPoller(30, 5);2poller.poll(new Action() {3 public void performAction() {4 if (btnSubmit.isElementPresent()) {5 btnSubmit.click();6 }7 }8});9ActionPoller poller = new ActionPoller(30, 5);10poller.poll(() -> {11 if (btnSubmit.isElementPresent()) {12 btnSubmit.click();13 }14});15ActionPoller poller = new ActionPoller(30, 5);16poller.poll(() -> btnSubmit.isElementPresent(), () -> btnSubmit.click());17ActionPoller poller = new ActionPoller(30, 5);18poller.poll(() -> btnSubmit.isElementPresent(), () -> btnSubmit.click(), () -> {19 throw new RuntimeException("Element is not present on the page after 30 seconds");20});

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Carina automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful