本文整理了Java中org.openqa.selenium.support.ui.WebDriverWait.until()
方法的一些代码示例,展示了WebDriverWait.until()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebDriverWait.until()
方法的具体详情如下:
包路径:org.openqa.selenium.support.ui.WebDriverWait
类名称:WebDriverWait
方法名:until
暂无
代码示例来源:origin: stackoverflow.com
// times out after 5 seconds
WebDriverWait wait = new WebDriverWait(driver, 5);
// while the following loop runs, the DOM changes -
// page is refreshed, or element is removed and re-added
wait.until(presenceOfElementLocated(By.id("container-element")));
// now we're good - let's click the element
driver.findElement(By.id("foo")).click();
代码示例来源:origin: stackoverflow.com
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.id("someid")));
代码示例来源:origin: stackoverflow.com
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword(**username**, **password**));
代码示例来源:origin: stackoverflow.com
public void checkAlert() {
try {
WebDriverWait wait = new WebDriverWait(driver, 2);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
alert.accept();
} catch (Exception e) {
//exception handling
}
}
代码示例来源:origin: apache/geode
private WebElement waitForElementById(final String id, int timeoutInSeconds) {
WebElement element =
(new WebDriverWait(driver, timeoutInSeconds, 1000))
.until((ExpectedCondition<WebElement>) d -> d.findElement(By.id(id)));
assertNotNull(element);
return element;
}
}
代码示例来源:origin: apache/geode
private void login() {
WebElement userNameElement = waitForElementById("user_name", 60);
WebElement passwordElement = waitForElementById("user_password");
userNameElement.sendKeys(username);
passwordElement.sendKeys(password);
passwordElement.submit();
driver.get(getPulseURL() + "clusterDetail.html");
WebElement userNameOnPulsePage =
(new WebDriverWait(driver, 30, 1000)).until(
(ExpectedCondition<WebElement>) d -> d.findElement(By.id("userName")));
assertNotNull(userNameOnPulsePage);
}
代码示例来源:origin: testcontainers/testcontainers-java
protected void doSimpleWebdriverTest(BrowserWebDriverContainer rule) {
RemoteWebDriver driver = setupDriverFromRule(rule);
System.out.println("Selenium remote URL is: " + rule.getSeleniumAddress());
System.out.println("VNC URL is: " + rule.getVncAddress());
driver.get("http://www.google.com");
WebElement search = driver.findElement(By.name("q"));
search.sendKeys("testcontainers");
search.submit();
List<WebElement> results = new WebDriverWait(driver, 15)
.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("#search h3")));
assertTrue("the word 'testcontainers' appears in search results",
results.stream()
.anyMatch(el -> el.getText().contains("testcontainers")));
}
代码示例来源:origin: la-team/light-admin
@Override
public void waitForElementVisible(final WebElement element, long timeout) {
new WebDriverWait(webDriver, timeout).until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return isElementPresent(element);
}
});
}
代码示例来源:origin: la-team/light-admin
@Override
public void waitForElementInvisible(final WebElement element) {
new WebDriverWait(webDriver, webDriverTimeout).until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return !isElementPresent(element);
}
});
}
代码示例来源:origin: la-team/light-admin
public static void assertImagePreviewIsDisplayed(String viewName, final WebElement webElement, final ExtendedWebDriver webDriver, final long timeout) {
try {
new WebDriverWait(webDriver, timeout).until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return webDriver.isElementPresent(webElement.findElement(By.xpath("//img[@name='picture']")));
}
});
} catch (TimeoutException e) {
fail("Image preview is not displayed on " + viewName);
}
}
代码示例来源:origin: TEAMMATES/teammates
/**
* Waits for the page to load. This includes all AJAX requests and Angular animations in the page.
*/
public void waitForPageLoad() {
WebDriverWait wait = new WebDriverWait(driver, TestProperties.TEST_TIMEOUT);
ExpectedCondition<Boolean> expectation = driver ->
"complete".equals(((JavascriptExecutor) driver).executeAsyncScript(PAGE_LOAD_SCRIPT).toString());
wait.until(expectation);
}
代码示例来源:origin: appium/java-client
@Test public void hideKeyboardWithParametersTest() {
new WebDriverWait(driver, 30)
.until(ExpectedConditions.presenceOfElementLocated(By.id("IntegerA")))
.click();
driver.hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done");
}
代码示例来源:origin: appium/java-client
@Test
public void openNotification() {
driver.closeApp();
driver.openNotifications();
WebDriverWait wait = new WebDriverWait(driver, 20);
assertNotEquals(0, wait.until(input -> {
List<AndroidElement> result = input
.findElements(id("com.android.systemui:id/settings_button"));
return result.isEmpty() ? null : result;
}).size());
}
}
代码示例来源:origin: appium/java-client
@Test public void webViewPageTestCase() throws InterruptedException {
new WebDriverWait(driver, 30)
.until(ExpectedConditions.presenceOfElementLocated(By.id("login")))
.click();
driver.findElementByAccessibilityId("webView").click();
new WebDriverWait(driver, 30)
.until(ExpectedConditions.presenceOfElementLocated(MobileBy.AccessibilityId("Webview")));
findAndSwitchToWebView();
WebElement el = driver.findElementByPartialLinkText("login");
assertTrue(el.isDisplayed());
}
}
代码示例来源:origin: appium/java-client
@Test public void dismissAlertTest() {
Supplier<Boolean> dismissAlert = () -> {
driver.findElement(MobileBy.AccessibilityId(iOSAutomationText)).click();
waiting.until(alertIsPresent());
driver.switchTo().alert().dismiss();
return true;
};
assertTrue(dismissAlert.get());
}
代码示例来源:origin: appium/java-client
@Test public void getAlertTextTest() {
driver.findElement(MobileBy.AccessibilityId(iOSAutomationText)).click();
waiting.until(alertIsPresent());
assertFalse(StringUtils.isBlank(driver.switchTo().alert().getText()));
}
}
代码示例来源:origin: appium/java-client
@Test
public void testLandscapeLeftRotation() {
new WebDriverWait(driver, 20).until(ExpectedConditions
.elementToBeClickable(driver.findElementById("android:id/content")
.findElement(MobileBy.AccessibilityId("Graphics"))));
DeviceRotation landscapeLeftRotation = new DeviceRotation(0, 0, 270);
driver.rotate(landscapeLeftRotation);
assertEquals(driver.rotation(), landscapeLeftRotation);
}
代码示例来源:origin: appium/java-client
@Test
public void testPortraitUpsideDown() {
new WebDriverWait(driver, 20).until(ExpectedConditions
.elementToBeClickable(driver.findElementById("android:id/content")
.findElement(MobileBy.AccessibilityId("Graphics"))));
DeviceRotation landscapeRightRotation = new DeviceRotation(0, 0, 180);
driver.rotate(landscapeRightRotation);
assertEquals(driver.rotation(), landscapeRightRotation);
}
代码示例来源:origin: appium/java-client
@Test
public void testLandscapeRightRotation() {
new WebDriverWait(driver, 20).until(ExpectedConditions
.elementToBeClickable(driver.findElementById("android:id/content")
.findElement(MobileBy.AccessibilityId("Graphics"))));
DeviceRotation landscapeRightRotation = new DeviceRotation(0, 0, 90);
driver.rotate(landscapeRightRotation);
assertEquals(driver.rotation(), landscapeRightRotation);
}
代码示例来源:origin: appium/java-client
@Test public void swipeTest() {
WebDriverWait webDriverWait = new WebDriverWait(driver, 30);
IOSElement slider = webDriverWait.until(driver1 -> driver.findElementByClassName("XCUIElementTypeSlider"));
Dimension size = slider.getSize();
ElementOption press = element(slider, size.width / 2 + 2, size.height / 2);
ElementOption move = element(slider, 1, size.height / 2);
TouchAction swipe = new TouchAction(driver).press(press)
.waitAction(waitOptions(ofSeconds(2)))
.moveTo(move).release();
swipe.perform();
assertEquals("0%", slider.getAttribute("value"));
}
内容来源于网络,如有侵权,请联系作者删除!