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


Java Alert.accept方法代码示例

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


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

示例1: execute

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
@Override
protected ExecuteResult execute(final WebSiteConnector connector) {
    try {
        final Alert alert = connector.getDriver().switchTo().alert();

        if (this.action == Action.ACCEPT) {
            alert.accept();

            LOGGER.info(LEARNER_MARKER, "Accept alert window (ignoreFailure: {}, negated: {}).",
                        ignoreFailure, negated);
        } else {
            alert.dismiss();

            LOGGER.info(LEARNER_MARKER, "Dismiss alert window (ignoreFailure: {}, negated: {}).",
                        ignoreFailure, negated);
        }

        return getSuccessOutput();
    } catch (NoAlertPresentException e) {
        LOGGER.info(LEARNER_MARKER, "Failed accept or dismiss alert window (ignoreFailure: {}, negated: {}).",
                    ignoreFailure, negated);

        return getFailedOutput();
    }
}
 
开发者ID:LearnLib,项目名称:alex,代码行数:26,代码来源:AlertAcceptDismissAction.java

示例2: clickAlert

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
/**
 * 切换到alter,并点击确认框
 */
public void clickAlert(String msg) {
	WebDriverWait webDriverWait = new WebDriverWait(driver, 10);
	Alert alert;
	baseOpt.wait(20);
	// Alert alert = driver.switchTo().alert();

	try { // 不稳定,原因待查。还是用上面的吧
	// wait and switchTo, Otherwise, throws a TimeoutException
		alert = webDriverWait.until(ExpectedConditions.alertIsPresent());
	} catch (Exception e) {
		this.screenShot();
		LogUtil.info(driver.manage().logs() + "==>alert等待超时!");
		alert = driver.switchTo().alert(); // 与waituntil功能重复,但until经常失败,为了增强健壮性才如此写
	}

	if (msg != null) {
		AssertUtil.assertEquals(alert.getText(), msg, "提示语错误");
	}

	alert.accept();
	baseOpt.wait(30);
}
 
开发者ID:quanqinle,项目名称:WebAndAppUITesting,代码行数:26,代码来源:WebBaseOpt.java

示例3: onCommand

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Object onCommand(Context context) {
    Alert alert = getSession().switchTo().alert();
    String text = alert.getText();

    Object value = getValue();
    if (value != null) {
        alert.sendKeys(value.toString());
    }

    if ("ok".equalsIgnoreCase(click)) {
        alert.accept();
    } else if ("close".equalsIgnoreCase(click)) {
        alert.dismiss();
    }

    return text;
}
 
开发者ID:niuxuetao,项目名称:paxml,代码行数:22,代码来源:AlertTag.java

示例4: isAlertPresent

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
/** Checks if an Alert is Present returns Boolean Value  **/
public static Boolean isAlertPresent(String controlType)
{
	try {			
		if (!controlType.equalsIgnoreCase("Alert"))
		{
			Alert alert = Automation.driver.switchTo().alert();	
			if(alert != null)
			{	
				TransactionMapping.report.strMessage=alert.getText();					
				alert.accept();							
				TransactionMapping.report.strStatus = "FAIL";
				TransactionMapping.pauseFun(TransactionMapping.report.strMessage);
				return true;
			}
		}
	} catch (Exception e) {				
		return false;
	}
	return false;		
}
 
开发者ID:MastekLtd,项目名称:SwiftLite,代码行数:22,代码来源:WebHelper.java

示例5: handlingSimpleAlertTest

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
@Test
public void handlingSimpleAlertTest() {
    final String expected_alert_text = "A Short Title Is Best A message should be a short, complete sentence.";

    driver.findElement(MobileBy.AccessibilityId("alert_views_button"))
            .click();
    //wait for alert view to load by waiting for "simple" alert button
    wait.until(ExpectedConditions.visibilityOf(driver.findElement(MobileBy.AccessibilityId("simple_alert_button"))))
            //and click on it
            .click();
    wait.until(ExpectedConditions.alertIsPresent());

    Alert alert = driver.switchTo().alert();
    String titleAndMessage = alert.getText();

    assertThat(titleAndMessage, is(expected_alert_text));
    alert.accept();
}
 
开发者ID:Simon-Kaz,项目名称:AppiumSauce,代码行数:19,代码来源:ParallelNativeIOSTest.java

示例6: closeAlertAndGetItsText

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
private String closeAlertAndGetItsText()
{
    try
    {
        Alert alert = driver.switchTo().alert();
        String alertText = alert.getText();
        if (acceptNextAlert)
        {
            alert.accept();
        }
        else
        {
            alert.dismiss();
        }
        return alertText;
    }
    finally
    {
        acceptNextAlert = true;
    }
}
 
开发者ID:hiroshitoda,项目名称:Selenium-sample-with-Jenkins,代码行数:22,代码来源:SimpleTest.java

示例7: clickOkButtonInConfirm

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
protected void clickOkButtonInConfirm(int timeoutForConfirm) {
    try {
        Alert alert = waitForAlertPresence(timeoutForConfirm);
        alert.accept();
    } catch (Exception ignored) {
    }
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:8,代码来源:AbstractWebContainer.java

示例8: confirmation

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
@Override
public String confirmation() {
    Alert alert = this.switchTo().alert();
    String alertText = alert.getText();
    alert.accept();
    return alertText;
}
 
开发者ID:Nonorc,项目名称:saladium,代码行数:8,代码来源:SaladiumDriver.java

示例9: closeAlertAndGetItsText

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
String closeAlertAndGetItsText() {
	try {
		Alert alert = getDriver().switchTo().alert();
		String alertText = alert.getText();
		if (acceptNextAlert) {
			alert.accept();
		} else {
			alert.dismiss();
		}
		return alertText;
	} finally {
		acceptNextAlert = true;
	}
}
 
开发者ID:chr-krenn,项目名称:chr-krenn-fhj-ws2017-sd17-pse,代码行数:15,代码来源:PageObject.java

示例10: acceptAlert

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
public  static final void acceptAlert(WebDriver driver){
	SeleniumWaitUtils.waitForAlert();
	Alert alert = driver.switchTo().alert();
	log.info("Alert: " + alert.getText());
	alert.accept();
	log.info("Accept Alter");	
}
 
开发者ID:21ca,项目名称:selenium-testng-template,代码行数:8,代码来源:SeleniumUtils.java

示例11: handleAlert

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
/**
 * This method handles alert windows
 **/
public static void handleAlert(String status, WebDriver driver) {
	Alert alert = driver.switchTo().alert();
	if (status.equalsIgnoreCase("Y")) {
		alert.accept();
	} else if (status.equalsIgnoreCase("N")) {
		alert.dismiss();
	}
}
 
开发者ID:AnujDasari,项目名称:Actitime-Framework,代码行数:12,代码来源:HelperManager.java

示例12: alertConfirm

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
/**
 * 点击确认按钮
 */
public void alertConfirm()
{
	Alert alert=driver.switchTo().alert();
	try {
		alert.accept();
		log.info("点击确认按钮");
	} catch (NoAlertPresentException notFindAlert) {
		// TODO: handle exception
		//throw notFindAlert;
		log.error("找不到确认按钮");
		throw notFindAlert;
	}
}
 
开发者ID:zhengshuheng,项目名称:PatatiumWebUi,代码行数:17,代码来源:ElementAction.java

示例13: AcceptPrompt

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
public void AcceptPrompt(String text) {
	
	if (!isAlertPresent())
		return;
	
	Alert alert = getAlert();
	alert.sendKeys(text);
	alert.accept();
	oLog.info(text);
}
 
开发者ID:rahulrathore44,项目名称:SeleniumCucumber,代码行数:11,代码来源:AlertHelper.java

示例14: alertAccept

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
/**
 * In case that alert is present, accept it, otherwise do nothing
 */
public void alertAccept() {
	try {
		Alert alert = driver().switchTo().alert();
		alert.accept();
	} catch(Exception ex) {
		// just ignore
	}
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:12,代码来源:WebDriverConnector.java

示例15: alertGetMessage

import org.openqa.selenium.Alert; //导入方法依赖的package包/类
@Nullable
public String alertGetMessage() {
	try {
		Alert alert = driver().switchTo().alert();
		String msg = alert.getText();
		alert.accept();
		return msg;
	} catch(Exception ex) {
		return null;
	}
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:12,代码来源:WebDriverConnector.java


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