long getTimeout(Config config, Object[] args) { try { if (args != null && args.length > 0) { return (long) args[0]; } else { return config.timeout(); } } catch (ClassCastException e) { throw new IllegalArgumentException("Unknown target type: " + Arrays.toString(args) + " (only long is supported)"); } } }
public File download(String url) throws IOException { return download(url, config.timeout()); }
private long getTimeoutMs(Method method, Object[] args) { return isWaitCommand(method) ? args.length == 3 ? (Long) args[args.length - 2] : (Long) args[args.length - 1] : config().timeout(); }
private SelenideWait Wait() { return new SelenideWait(webDriver, config.timeout(), config.pollingInterval()); } }
/** * For example: {@code $$(".error").shouldBe(empty)} */ public ElementsCollection shouldBe(CollectionCondition... conditions) { return should("be", driver().config().timeout(), conditions); }
/** * For example: * {@code $$(".error").shouldHave(size(3))} * {@code $$(".error").shouldHave(texts("Error1", "Error2"))} */ public ElementsCollection shouldHave(CollectionCondition... conditions) { return should("have", driver().config().timeout(), conditions); }
public SelenideWait Wait() { return new SelenideWait(getWebDriver(), config().timeout(), config().pollingInterval()); }
@Override public File execute(SelenideElement proxy, WebElementSource locator, Object[] args) throws IOException { File[] file; if (args instanceof File[]) { file = (File[]) args; } else { file = (File[]) args[0]; } if (file.length == 0) { throw new IllegalArgumentException("No files to upload"); } WebElement inputField = locator.getWebElement(); File uploadedFile = uploadFile(locator.driver(), inputField, file[0]); if (file.length > 1) { SelenideElement form = proxy.closest("form"); List<WebElement> newInputs = cloneInputField(locator.driver(), form, inputField, file.length - 1); Config config = locator.driver().config(); Stopwatch stopwatch = new Stopwatch(config.timeout()); for (int i = 1; i < file.length; i++) { WebElement newInput = newInputs.get(i - 1); uploadSingleFile(config, file[i], stopwatch, newInput); } } return uploadedFile; }