本文整理汇总了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;
}
}