本文整理汇总了Java中org.openqa.selenium.support.ui.ExpectedConditions类的典型用法代码示例。如果您正苦于以下问题:Java ExpectedConditions类的具体用法?Java ExpectedConditions怎么用?Java ExpectedConditions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExpectedConditions类属于org.openqa.selenium.support.ui包,在下文中一共展示了ExpectedConditions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: switchFrame
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
private void switchFrame(String frameData) {
try {
if (frameData != null && !frameData.trim().isEmpty()) {
driver.switchTo().defaultContent();
if (frameData.trim().matches("[0-9]+")) {
driver.switchTo().frame(Integer.parseInt(frameData.trim()));
} else {
WebDriverWait wait = new WebDriverWait(driver,
SystemDefaults.waitTime.get());
wait.until(ExpectedConditions
.frameToBeAvailableAndSwitchToIt(frameData));
}
}
} catch (Exception ex) {
//Error while switching to frame
}
}
示例2: findElement
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
/**
* 通用的元素查找方法
* @param by 具体的查找方法
* @return
*/
private WebElement findElement(By by)
{
WebDriver driver = engine.getDriver();
driver = engine.turnToRootDriver(driver);
if(element.getTimeOut() > 0)
{
WebDriverWait wait = new WebDriverWait(driver, element.getTimeOut());
wait.until(ExpectedConditions.visibilityOfElementLocated(by));
}
if(parentElement != null)
{
return parentElement.findElement(by);
}
else
{
return driver.findElement(by);
}
}
示例3: run
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
@Override
public void run(RecordingSimulatorModule recordingSimulatorModule) {
String baseUrl = (String) opts.get(URL);
WebDriver driver = recordingSimulatorModule.getWebDriver();
WebDriverWait wait = new WebDriverWait(driver, 10);
driver.get(baseUrl + Pages.CLICK_CLASS_BY_TEXT_DEMO_PAGE);
Optional<WebElement> webElementOptional = driver.findElements(By.className("item"))
.stream()
.filter(webElement -> webElement.getText().equals(TARGET))
.findAny();
assertTrue(webElementOptional.isPresent());
webElementOptional.get().click();
wait.until(ExpectedConditions.elementToBeClickable(By.id("success-indicator")));
}
示例4: run
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
@Override
public void run() {
super.run();
By locator = this.readLocatorArgument("locator");
this.waitForAsyncCallsToFinish();
try {
WebElement element = this.getElement(locator);
WebDriverWait wait = new WebDriverWait(this.driver, this.explicitWaitSec);
wait.until(ExpectedConditions.elementToBeClickable(element));
element.clear();
} catch (Exception ex) {
throw new RuntimeException(String.format(
"Failed clicking on element %s",
locator), ex);
}
}
示例5: checkJHipsterSampleAppPage
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
/**
* Check JHipsterSampleApp portal page.
*
* @throws FailureException
* if the scenario encounters a functional error.
*/
@Then("The JHIPSTERSAMPLEAPP portal is displayed")
public void checkJHipsterSampleAppPage() throws FailureException {
try {
Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(jHipsterSampleAppPage.signInMessage)));
if (!jHipsterSampleAppPage.isDisplayed()) {
logInToJHipsterSampleAppWithNoraRobot();
}
if (!jHipsterSampleAppPage.checkPage()) {
new Result.Failure<>(jHipsterSampleAppPage.getApplication(), Messages.FAIL_MESSAGE_UNKNOWN_CREDENTIALS, true, jHipsterSampleAppPage.getCallBack());
}
} catch (Exception e) {
new Result.Failure<>(jHipsterSampleAppPage.getApplication(), Messages.FAIL_MESSAGE_UNKNOWN_CREDENTIALS, true, jHipsterSampleAppPage.getCallBack());
}
Auth.setConnected(true);
}
示例6: searchFor
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
/**
* Types into the search bar in the top right and searches.
*
* @param content
* - The value to type into the search bar.
*/
public void searchFor(String content) {
this.focusForm(false);
WebElement mGTypeArea = _wait.until(ExpectedConditions.presenceOfElementLocated(By.name("sysparm_search")));
if (!mGTypeArea.getClass().toString().contains("focus")) {
WebElement magnifyingGlass = _wait
.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("[action='textsearch.do']")));
magnifyingGlass.click();
}
if(!mGTypeArea.getAttribute("value").equalsIgnoreCase("")) {
mGTypeArea.clear();
}
mGTypeArea.sendKeys(content);
mGTypeArea.sendKeys(Keys.ENTER);
}
示例7: updateText
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
/**
* Update a html input text with a text.
*
* @param pageElement
* Is target element
* @param textOrKey
* Is the new data (text or text in context (after a save))
* @param keysToSend
* character to send to the element after {@link org.openqa.selenium.WebElement#sendKeys(CharSequence...) sendKeys} with textOrKey
* @param args
* list of arguments to format the found selector with
* @throws TechnicalException
* is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
* Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_ERROR_ON_INPUT} message (with screenshot, no exception)
* @throws FailureException
* if the scenario encounters a functional error
*/
protected void updateText(PageElement pageElement, String textOrKey, CharSequence keysToSend, Object... args) throws TechnicalException, FailureException {
String value = Context.getValue(textOrKey) != null ? Context.getValue(textOrKey) : textOrKey;
if (!"".equals(value)) {
try {
WebElement element = Context.waitUntil(ExpectedConditions.elementToBeClickable(Utilities.getLocator(pageElement, args)));
element.clear();
if (DriverFactory.IE.equals(Context.getBrowser())) {
String javascript = "arguments[0].value='" + value + "';";
((JavascriptExecutor) getDriver()).executeScript(javascript, element);
} else {
element.sendKeys(value);
}
if (keysToSend != null) {
element.sendKeys(keysToSend);
}
} catch (Exception e) {
new Result.Failure<>(e.getMessage(), Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_ERROR_ON_INPUT), pageElement, pageElement.getPage().getApplication()), true,
pageElement.getPage().getCallBack());
}
} else {
logger.debug("Empty data provided. No need to update text. If you want clear data, you need use: \"I clear text in ...\"");
}
}
示例8: doCreditCardPaymentOnPaymentPanel
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
private void doCreditCardPaymentOnPaymentPanel(Payment response) {
RemoteWebDriver driver = openFirefoxAtUrl(response.getRedirectLocation());
driver.findElement(By.name("selCC|VISA")).click();
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.id("cardnumber")));
driver.findElement(By.id("cardnumber")).sendKeys("4444333322221111");
driver.findElement(By.id("cvc")).sendKeys("123");
(new Select(driver.findElement(By.id("expiry-month")))).selectByValue("05");
(new Select(driver.findElement(By.id("expiry-year")))).selectByValue(getYear());
driver.findElement(By.name("profile_id")).sendKeys("x");
driver.findElement(By.id("right")).click();
wait.until(ExpectedConditions.elementToBeClickable(By.id("right")));
driver.findElement(By.id("right")).click();
}
示例9: selectCheckbox
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
/**
* Checks a checkbox type element (value corresponding to key "valueKey").
*
* @param element
* Target page element
* @param valueKeyOrKey
* is valueKey (valueKey or key in context (after a save)) to match in values map
* @param values
* Values map
* @throws TechnicalException
* is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
* Failure with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_CHECK_ELEMENT} message (with screenshot)
* @throws FailureException
* if the scenario encounters a functional error
*/
protected void selectCheckbox(PageElement element, String valueKeyOrKey, Map<String, Boolean> values) throws TechnicalException, FailureException {
String valueKey = Context.getValue(valueKeyOrKey) != null ? Context.getValue(valueKeyOrKey) : valueKeyOrKey;
try {
WebElement webElement = Context.waitUntil(ExpectedConditions.elementToBeClickable(Utilities.getLocator(element)));
Boolean checkboxValue = values.get(valueKey);
if (checkboxValue == null) {
checkboxValue = values.get("Default");
}
if (webElement.isSelected() != checkboxValue.booleanValue()) {
webElement.click();
}
} catch (Exception e) {
new Result.Failure<>(e.getMessage(), Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_CHECK_ELEMENT), element, element.getPage().getApplication()), true,
element.getPage().getCallBack());
}
}
示例10: checkDemoPortalPage
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
@Alors("Le portail COUNTRIES est affiché")
@Then("The COUNTRIES portal is displayed")
public void checkDemoPortalPage() throws FailureException {
try {
Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(dashboardPage.signInMessage)));
if (!dashboardPage.checkPage()) {
logInToCountriesWithCountriesRobot();
}
if (!dashboardPage.checkPage()) {
new Result.Failure<>(dashboardPage.getApplication(), Messages.getMessage(Messages.FAIL_MESSAGE_UNKNOWN_CREDENTIALS), true, dashboardPage.getCallBack());
}
} catch (Exception e) {
new Result.Failure<>(dashboardPage.getApplication(), Messages.getMessage(Messages.FAIL_MESSAGE_UNKNOWN_CREDENTIALS), true, dashboardPage.getCallBack());
}
Auth.setConnected(true);
}
示例11: etrePlein
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
@Override
public void etrePlein(String type, String selector) {
this.logger.info("etrePlein(String id)");
By locator = BySelec.get(type, selector);
WebElement elem = wait.until(ExpectedConditions.presenceOfElementLocated(locator));
if (elem.getAttribute("value") != null) {
if (elem.getAttribute("value").toString().trim().isEmpty()) {
Assert.fail("l'élément ne devrait pas être vide!");
}
} else {
if (elem.getText().trim().isEmpty()) {
Assert.fail("l'élément ne devrait pas être vide!");
}
}
}
示例12: testShippingAddressWithStreet2
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
@Test
public void testShippingAddressWithStreet2() throws PaymentException {
Payment response = mpay24.paymentPage(getTestPaymentRequest(), getCustomerWithAddress("Coconut 3"));
assertSuccessfullResponse(response);
RemoteWebDriver driver = openFirefoxAtUrl(response.getRedirectLocation());
driver.findElement(By.name("selPAYPAL|PAYPAL")).click();
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.name("BillingAddr/Street")));
assertEquals("Testperson-de Approved", driver.findElement(By.name("BillingAddr/Name")).getAttribute("value"));
assertEquals("Hellersbergstraße 14", driver.findElement(By.name("BillingAddr/Street")).getAttribute("value"));
assertEquals("Coconut 3", driver.findElement(By.name("BillingAddr/Street2")).getAttribute("value"));
assertEquals("41460", driver.findElement(By.name("BillingAddr/Zip")).getAttribute("value"));
assertEquals("Neuss", driver.findElement(By.name("BillingAddr/City")).getAttribute("value"));
assertEquals("Ankeborg", driver.findElement(By.name("BillingAddr/State")).getAttribute("value"));
assertEquals("Deutschland", driver.findElement(By.name("BillingAddr/Country/@Code")).findElement(By.xpath("option[@selected='']")).getText());
}
示例13: visit
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
@Override
public void visit(WebDriver driver, String url) {
final int implicitWait = Integer.parseInt(properties.getProperty("caching.page_load_wait"));
driver.manage().timeouts().implicitlyWait(implicitWait, TimeUnit.SECONDS);
driver.get(url);
LOGGER.fine("Wait for JS complete");
(new WebDriverWait(driver, implicitWait)).until((ExpectedCondition<Boolean>) d -> {
final String status = (String) ((JavascriptExecutor) d).executeScript("return document.readyState");
return status.equals("complete");
});
LOGGER.fine("JS complete");
LOGGER.fine("Wait for footer");
(new WebDriverWait(driver, implicitWait))
.until(
ExpectedConditions.visibilityOf(
driver.findElement(By.name("downarrow"))));
LOGGER.info("Footer is there");
try {
Thread.sleep(implicitWait * 1000l);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
示例14: esperaCargaPaginaNoTexto
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
static public void esperaCargaPaginaNoTexto(WebDriver driver, String texto, int timeout)
{
Boolean resultado =
(new WebDriverWait(driver, timeout)).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[contains(text(),'" + texto + "')]")));
assertTrue(resultado);
}
示例15: clickButtonOnModalDialogOnce
import org.openqa.selenium.support.ui.ExpectedConditions; //导入依赖的package包/类
private void clickButtonOnModalDialogOnce(String buttonText) {
helper.findElement(
By.xpath("//div[contains(@class, 'wicket-modal')]//input[@type='submit' and @value='"+ buttonText +"']"))
.click();
helper.waitForElementUntil(ExpectedConditions.invisibilityOfElementLocated(
By.xpath("//div[contains(@class, 'wicket-modal')]")));
}