當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。