How to use createDriver method of org.testingisdocumenting.webtau.browser.driver.WebDriverCreator class

Best Webtau code snippet using org.testingisdocumenting.webtau.browser.driver.WebDriverCreator.createDriver

Source:WebDriverCreator.java Github

copy

Full Screen

...47 WebTauStep step = WebTauStep.createStep(48 tokenizedMessage(action("initializing"), classifier("webdriver"), FOR, id(BrowserConfig.getBrowserId())),49 () -> tokenizedMessage(action("initialized"), classifier("webdriver"), FOR, id(BrowserConfig.getBrowserId())),50 () -> {51 WebDriver driver = createDriverWithAutoRetry();52 initState(driver);53 register(driver);54 return driver;55 });56 return step.execute(StepReportOptions.REPORT_ALL);57 }58 public static void quitAll() {59 drivers.forEach(WebDriverCreator::quitWithoutRemove);60 drivers.clear();61 }62 public static boolean hasActiveBrowsers() {63 return !drivers.isEmpty();64 }65 static void quit(WebDriver driver) {66 quitWithoutRemove(driver);67 drivers.remove(driver);68 }69 private static void quitWithoutRemove(WebDriver driver) {70 WebDriverCreatorListeners.beforeDriverQuit(driver);71 try {72 driver.quit();73 } catch (Throwable ignore) {74 }75 WebDriverCreatorListeners.afterDriverQuit(driver);76 }77 // after selenium 4 upgrade driver is not being created 100% of the time in GitHub CI78 // maybe there is a hidden race condition in webtau feature tests79 // for now we add auto retry80 private static WebDriver createDriverWithAutoRetry() {81 int numberOfAttempts = 5;82 int attemptNumber = 1;83 while (attemptNumber < numberOfAttempts) {84 try {85 return createDriver();86 } catch (RuntimeException e) {87 // ignore88 }89 attemptNumber++;90 }91 return createDriver();92 }93 private static WebDriver createDriver() {94 return BrowserConfig.isRemoteDriver() ?95 createRemoteDriver() :96 createLocalDriver();97 }98 private static WebDriver createRemoteDriver() {99 if (BrowserConfig.isChrome()) {100 return createRemoteChromeDriver();101 }102 if (BrowserConfig.isFirefox()) {103 return createRemoteFirefoxDriver();104 }105 return throwUnsupportedBrowser();106 }107 private static WebDriver createLocalDriver() {...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful