0
팝업이 있는지 확인하고 싶으면 예를 선택하고 그렇지 않으면 동의하십시오. 친절하게 내가 셀레늄을 처음 사용하는 것처럼 돕는다. 나는 자바를 사용하고있다. 감사.경고가 있는지 확인한 다음 예 (그렇다면 수락)를 확인하는 방법
팝업이 있는지 확인하고 싶으면 예를 선택하고 그렇지 않으면 동의하십시오. 친절하게 내가 셀레늄을 처음 사용하는 것처럼 돕는다. 나는 자바를 사용하고있다. 감사.경고가 있는지 확인한 다음 예 (그렇다면 수락)를 확인하는 방법
이렇게 될 것입니다.
WebDriverWait wait = new WebDriverWait(driver, 10 /*timeout in seconds*/);
if(wait.until(ExpectedConditions.alertIsPresent())==null){
System.out.println("alert was not present");
}
else
{
Alert alert = driver.switchTo().alert();
alert.accept();
System.out.println("alert was present and accepted");
}
나는이 당신을 것 같아요 :
이@Test
public void testAlertOk()
{
//Now we would click on AlertButton
WebElement button = driver.findElement(By.id("AlerButton"));
button.click();
try {
//Now once we hit AlertButton we get the alert
Alert alert = driver.switchTo().alert();
//Text displayed on Alert using getText() method of Alert class
String AlertText = alert.getText();
//accept() method of Alert Class is used for ok button
alert.accept();
//Verify Alert displayed correct message to user
assertEquals("this is alert box",AlertText);
} catch (Exception e) {
e.printStackTrace();
}
}
user3122524 @ 작동하는지 알려주세요. – newLearner