当前位置: 首页>>代码示例>>Java>>正文


Java WebDriverWait.until方法代码示例

本文整理汇总了Java中org.openqa.selenium.support.ui.WebDriverWait.until方法的典型用法代码示例。如果您正苦于以下问题:Java WebDriverWait.until方法的具体用法?Java WebDriverWait.until怎么用?Java WebDriverWait.until使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.support.ui.WebDriverWait的用法示例。


在下文中一共展示了WebDriverWait.until方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: swipeAndCheckElementVisible

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
protected void swipeAndCheckElementVisible(By locator, String direction) {
    Logger.trace(String.format("AppiumTestAction.swipeAndCheckElementVisible (%s, %s)",
            locator,
            direction));

    if (direction.equalsIgnoreCase("none")) {
        WebDriverWait wait = new WebDriverWait(driver, AppiumHelper.getExplicitWaitSec());
        wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
    } else {
        // TODO: Revisit this and implement a smarter algorithm - not ok to repeat this for an arbitrary number of times
        int maxSwipeCount = Integer.valueOf(AppiumTestAction.config.getString("appium.maxSwipeCount", "50"));

        for (int i = 0; i < maxSwipeCount; i++) {
            try {
                Logger.trace(String.format("AppiumTestAction.swipeAndCheckElementVisible iteration %s", i + 1));
                waitForElementVisible(locator, 1);
                return;
            } catch (Exception ex) {
                swipe(direction);
            }
        }

        throw new RuntimeException(String.format("Element was not visible: %s", locator.toString()));
    }
}
 
开发者ID:mcdcorp,项目名称:opentest,代码行数:26,代码来源:AppiumTestAction.java

示例2: waitForPageToLoad

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
protected Boolean waitForPageToLoad() {
    JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
    WebDriverWait wait = new WebDriverWait(driver, 10); //give up after 10 seconds

    //keep executing the given JS till it returns "true", when page is fully loaded and ready
    return wait.until((ExpectedCondition<Boolean>) input -> {
        String res = jsExecutor.executeScript("return /loaded|complete/.test(document.readyState);").toString();
        return Boolean.parseBoolean(res);
    });
}
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:11,代码来源:PageObject.java

示例3: atc

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
public void atc() {
	WebDriverWait wait = new WebDriverWait(driver, 300L);
	
	wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@class='ffSelectButton' and (.//span[text()[contains(.,'Size')]] or .//span[text()[contains(.,'size')]])]")));
	
	int index = new Random().nextInt(sizes.length);
	String sizeToPick = Double.toString(sizes[index]);
	
	for(WebElement e : driver.findElements(By.xpath("//div[@class='ffSelectMenuMid' and .//ul[.//li[.//span[text()[contains(.,'size')]]]]]/ul/li"))) {
		String size = e.getText().trim();
		if(size != null && size.equals(sizeToPick)) {
			e.click();
			break;
		}
	}	
}
 
开发者ID:Penor,项目名称:SneakerBot,代码行数:17,代码来源:Adidas.java

示例4: switchToNewWindow

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
@Override
public void switchToNewWindow() {
    WebDriver driver = webPage.getDriver();
    baseWindowHandle = driver.getWindowHandle();
    Thucydides.getCurrentSession().put("baseWindowHandle",
            baseWindowHandle);
    Set<String> openedWindows = driver.getWindowHandles();
    String newWindow = null;
    if (openedWindows.size() > 1 && openedWindows.remove
            (baseWindowHandle)) {
        Iterator<String> openedWindowsIterator = openedWindows.iterator();
        newWindow = openedWindowsIterator.next();
    } else {
        int timeout = getSatisfyWebProperties().getSatisfyWait();
        WebDriverWait wait = new WebDriverWait(driver, timeout);
        newWindow = wait.until(anyWindowOtherThan(openedWindows));
    }
    driver.switchTo().window(newWindow);
}
 
开发者ID:tapack,项目名称:satisfy,代码行数:20,代码来源:BasePageSteps.java

示例5: explicitWait

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
/**
 * This method makes the driver wait till the webelement is located
 **/
public static void explicitWait(WebElement wb, WebDriver driver) {
	try {
		WebDriverWait wait = new WebDriverWait(driver, 20);
		wait.until(ExpectedConditions.visibilityOf(wb));
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:AnujDasari,项目名称:Actitime-Framework,代码行数:12,代码来源:HelperManager.java

示例6: isAlertPresent

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
public boolean isAlertPresent() {
    WebDriverWait wait = new WebDriverWait(driver, 0);
    try {
        wait.until(ExpectedConditions.alertIsPresent());
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:10,代码来源:ControllerBase.java

示例7: switchTo

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
/**
 * 等待frame可以用,切换到指定的frame
 * 
 * @param by
 */
public void switchTo(By frameby) {
	WebDriverWait webDriverWait = new WebDriverWait(driver, DRIVER_WAIT_TIMEOUT_IN_SECOND);
	try {
		// wait and switchTo, Otherwise, throws a TimeoutException
		webDriverWait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameby));
		// driver.switchTo().frame(this.findElement(frameby));
		LogUtil.info(driver.manage().logs() + "==>switchTo frame:" + frameby.toString() + "成功.");
	} catch (Exception e) {
		this.screenShot();
		LogUtil.info(driver.manage().logs() + "==>switchTo frame:" + frameby.toString() + "等待超时!");
		driver.switchTo().frame(this.findElement(frameby)); // 与waituntil功能重复,但until经常失败,为了增强健壮性才如此写
	}
}
 
开发者ID:quanqinle,项目名称:WebAndAppUITesting,代码行数:19,代码来源:WebBaseOpt.java

示例8: SettingsViewButton

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
@Test
public void SettingsViewButton() { 
	WebDriverWait wait = new WebDriverWait(driver, 10);
	WebElement menuButton = driver.findElement(By.xpath("//android.widget.ImageButton[@content-desc=\"Open navigation\"]"));
    menuButton.click();
    WebElement settingsViewButton = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@text=\"Settings\"]"))));
    settingsViewButton.click();
}
 
开发者ID:ark-konopacki,项目名称:appium_tutorial,代码行数:9,代码来源:AndroidTest.java

示例9: click

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
/**
 * Click on an element.
 * 
 * @param locator
 *            - element locator
 * @param replacement
 *            - if element contains dynamic part, i.e. '$value' in locator
 *            part, then '$value' part will be replaced by replacement value
 * @param ignoreNoSuchElementException
 *            - if set to true, then no exceptions will be thrown when
 *            element is not found, Suitable for situations where you want
 *            the test to progress despite of the result that click action
 *            succeeded or not!
 * @throws PropertyNotFoundException
 *             - throw this exception when declared locator is not found in
 *             object repository
 * @throws InvalidLocatorStrategyException
 *             - throw this exception when locator strategy is wrong. Valid
 *             locator strategies are 'ID', 'XPATH', 'NAME', 'CSS_SELECTOR',
 *             'CLASS_NAME', 'LINK_TEXT', 'PARTIAL_LINK_TEXT' and 'TAG_NAME'
 */
public void click(String locator, String replacement, boolean ignoreNoSuchElementException)
        throws PropertyNotFoundException, InvalidLocatorStrategyException
{
    if (replacement != null)
    {
        if (locator.contains("$value"))
        {
            locator = locator.replace("$value", replacement);
        }
    }

    if (ignoreNoSuchElementException)
    {
        try
        {
            element = ElementFinder.findElement(driver, locator);
        } catch (NoSuchElementException ex)
        {
            return;
        }
    } else
    {
        element = ElementFinder.findElement(driver, locator);

        WebDriverWait wait = new WebDriverWait(driver, 15);
        wait.until(ExpectedConditions.elementToBeClickable(element));

        element.click();

        LOGGER.info("Successfully clicked on element '" + locator + "' with locator value '"
                + props.getProperty(locator) + "'");
    }
}
 
开发者ID:pradeeptaswain,项目名称:oldmonk,代码行数:55,代码来源:BasePage.java

示例10: isAlertPresent

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
/**
 * Check for alert presence.
 * 
 * @return - true if an alert is present
 */
public boolean isAlertPresent(){
	boolean foundAlert = false;
	// check for alert presence with no timeout (0 seconds)
	WebDriverWait wait = new WebDriverWait(driver, 0);
	try {
		wait.until(ExpectedConditions.alertIsPresent());
		foundAlert = true;
	} catch (TimeoutException eTO) {
		foundAlert = false;
	}
	return foundAlert;
}
 
开发者ID:danrusu,项目名称:mobileAutomation,代码行数:18,代码来源:TestCase.java

示例11: OverViewButton

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
@Test
public void OverViewButton() {
	WebDriverWait wait = new WebDriverWait(driver, 10);
	WebElement menuButton = driver.findElement(By.xpath("//android.widget.ImageButton[@content-desc=\"Open navigation\"]"));
	menuButton.click();   
    WebElement overViewButton = wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@text=\"Overview\"]"))));
    overViewButton.click();
}
 
开发者ID:ark-konopacki,项目名称:appium_tutorial,代码行数:9,代码来源:AndroidTest.java

示例12: waitForPageToLoad

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
public void waitForPageToLoad()
{
    JavaScriptHelper js = new JavaScriptHelper();
    ExpectedCondition expectedCondition = new ExpectedCondition<Boolean>(){
        public Boolean apply(WebDriver driver){
            return js.executeScript( "return document.readyState" ).equals( "complete" );
        }
    };

    WebDriverWait wait = new WebDriverWait(driver, SessionContextManager.getWaitForPageToLoad(), THREAD_SLEEP);
    wait.until(expectedCondition);

    wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.tagName("div")));
}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:15,代码来源:WebDriverWebController.java

示例13: waitForElementInvisibility

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
/**
 * waitForElementInvisibility(java.lang.String, long)
 */

public void waitForElementInvisibility(String locator, long waitSeconds) {
    try {
        WebDriverWait wait = new WebDriverWait(driver, waitSeconds);
        wait.until(ExpectedConditions.invisibilityOfElementLocated(determineLocator(locator)));
    } catch (Exception e) {
        takeScreenShot();
        throw new TimeoutException("Exception has been thrown", e);
    }

}
 
开发者ID:hemano,项目名称:cucumber-framework-java,代码行数:15,代码来源:ControllerBase.java

示例14: DescribeComponentPage

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
public DescribeComponentPage(WebDriver driver)
{
    super(driver);
    WebDriverWait wait = new WebDriverWait(driver, 10);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(".component_name")));
}
 
开发者ID:mwinteringham,项目名称:api-webdriver-harmony,代码行数:7,代码来源:DescribeComponentPage.java

示例15: explicitWaitElementToBeClickable

import org.openqa.selenium.support.ui.WebDriverWait; //导入方法依赖的package包/类
/** To Wait Until Element to be Clickable */	
public static void explicitWaitElementToBeClickable(WebElement element, int time) 
{
	WebDriverWait clickableWait = new WebDriverWait(driver, time);
	clickableWait.until(ExpectedConditions.elementToBeClickable(element));
}
 
开发者ID:GladsonAntony,项目名称:WebAutomation_AllureParallel,代码行数:7,代码来源:ExplicitWaiting.java


注:本文中的org.openqa.selenium.support.ui.WebDriverWait.until方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。