private SelenideWait Wait() { return new SelenideWait(webDriver, config.timeout(), config.pollingInterval()); } }
public SelenideWait(WebDriver input, long timeout, long pollingInterval) { super(input); withTimeout(Duration.of(timeout, ChronoUnit.MILLIS)); pollingEvery(Duration.of(pollingInterval, ChronoUnit.MILLIS)); } }
/** * Switch to window/tab by name/handle/title * @param nameOrHandleOrTitle name or handle or title of window/tab */ @Override public WebDriver window(String nameOrHandleOrTitle) { try { return Wait().until(windowToBeAvailableAndSwitchToIt(nameOrHandleOrTitle)); } catch (TimeoutException e) { throw new NoSuchWindowException("No window found with name or handle or title: " + nameOrHandleOrTitle, e); } }
@Override public Alert alert() { try { return Wait().until(alertIsPresent()); } catch (TimeoutException e) { throw new NoAlertPresentException("Alert not found", e); } }
public SelenideWait Wait() { return new SelenideWait(getWebDriver(), config().timeout(), config().pollingInterval()); }
/** * Switch to window/tab by index * NB! Order of windows/tabs can be different in different browsers, see Selenide tests. * @param index index of window (0-based) */ public WebDriver window(int index) { try { return Wait().until(windowToBeAvailableAndSwitchToIt(index)); } catch (TimeoutException e) { throw new NoSuchWindowException("No window found with index: " + index, e); } }
/** * Switch to the inner frame (last child frame in given sequence) */ public WebDriver innerFrame(String... frames) { delegate.defaultContent(); for (String frame : frames) { try { String selector = String.format("frame#%1$s,frame[name=%1$s],iframe#%1$s,iframe[name=%1$s]", frame); Wait().until(frameToBeAvailableAndSwitchToIt_fixed(By.cssSelector(selector))); } catch (NoSuchElementException | TimeoutException e) { throw new NoSuchFrameException("No frame found with id/name = " + frame, e); } } return webDriver; }
@Override public WebDriver frame(int index) { try { return Wait().until(frameToBeAvailableAndSwitchToIt(index)); } catch (NoSuchElementException | TimeoutException e) { throw new NoSuchFrameException("No frame found with index: " + index, e); } catch (InvalidArgumentException e) { throw isFirefox62Bug(e) ? new NoSuchFrameException("No frame found with index: " + index, e) : e; } }
@Override public WebDriver frame(WebElement frameElement) { try { return Wait().until(frameToBeAvailableAndSwitchToIt(frameElement)); } catch (NoSuchElementException | TimeoutException e) { throw new NoSuchFrameException("No frame found with element: " + frameElement, e); } catch (InvalidArgumentException e) { throw isFirefox62Bug(e) ? new NoSuchFrameException("No frame found with element: " + frameElement, e) : e; } }
@Override public WebDriver frame(String nameOrId) { try { return Wait().until(frameToBeAvailableAndSwitchToIt(nameOrId)); } catch (NoSuchElementException | TimeoutException e) { throw new NoSuchFrameException("No frame found with id/name: " + nameOrId, e); } catch (InvalidArgumentException e) { throw isFirefox62Bug(e) ? new NoSuchFrameException("No frame found with id/name: " + nameOrId, e) : e; } }