Internet Explorer 및 셀레늄에서 "모달 대화 상자 있음 :이 페이지를 나가면 변경 사항이 손실됩니다"를 해결하는 방법은 무엇입니까?

들음

다음은 내 코드입니다. 아래 코드는 경고 상자를 제거 할 수 있지만 콘솔에서는 오류가 발생합니다.

스레드 "main"의 예외 org.openqa.selenium.UnhandledAlertException : 모달 대화 상자 있음 :이 페이지에서 나가면 모든 변경 사항이 손실됩니다. 빌드 정보 : 버전 : '3.0.1', 수정 : '1969d75', 시간 : '2016-10-18 09:48:19 -0700' "인테넷 익스플로러 11을 사용하고 있습니다.

driver.findElement(By.xpath("//div[@id=ctl02_cp1_ucGI")).click();

Thread.sleep(4000);
if (ExpectedConditions.alertIsPresent() != null)
{
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("window.onbeforeunload = function() {};"); 
    System.out.println("alert is present");
}
else
{
    System.out.println("alert is not present");
}

Thread.sleep(4000);
WebElement product1=driver.findElement(By.xpath("//select[@id='ctl00_cp1_ucGI_ddlProduct']"));
도마

셀레늄을 통해 경고를 수락 할 수 있습니다.

public void checkAlert() 
{
    try 
    {
        // Wait for the alert is present
        WebDriverWait wait = new WebDriverWait(driver, 2);
        wait.until(ExpectedConditions.alertIsPresent());

        // Switch to the alert
        Alert alert = driver.switchTo().alert();

        // Close the alert
        alert.accept();
    } 
    catch (Exception e) 
    {
        //exception handling
    }
}

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관