本文整理匯總了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();
}
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}
示例7: clickOkButtonInConfirm
import org.openqa.selenium.Alert; //導入方法依賴的package包/類
protected void clickOkButtonInConfirm(int timeoutForConfirm) {
try {
Alert alert = waitForAlertPresence(timeoutForConfirm);
alert.accept();
} catch (Exception ignored) {
}
}
示例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;
}
示例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;
}
}
示例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");
}
示例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();
}
}
示例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;
}
}
示例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);
}
示例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
}
}
示例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;
}
}