Module 24 issue alert is not detect by browser | Selenium Forum
K
Khushali Prabhubhai Patel Posted on 28/05/2020

AcceptAlert() is not working. it throws timeout exception

public void AcceptAlert(){

try{

WebDriverWait wait = new WebDriverWait(driver, 29);

    wait.until(ExpectedConditions.alertIsPresent());

    Alert alert = driver.switchTo().alert();

    alert.accept();

    System.out.println("alert was present and accepted");

}

catch(Exception e) {

    System.out.println("alert was not present");

    System.out.print(e);

 

}

}

 

Error:

org.openqa.selenium.TimeoutException: Timed out after 29 seconds waiting for alert to be present


A
Ashish Thakur Replied on 28/05/2020

On which URL are you trying this code



A
Ashish Thakur Replied on 29/05/2020

I am not getting any alert on this URL


K
Khushali Prabhubhai Patel Replied on 29/05/2020

Delete Popup is appeared when i try to delete a Lead

 


A
Ashish Thakur Replied on 01/06/2020

Ok.. please use explicit wait and wait till the alert is present


K
Khushali Prabhubhai Patel Replied on 03/06/2020

I have alredy used explict wait and wait till alert is present. Its not working .

it throws timeout exception

publicvoidAcceptAlert(){

try{

WebDriverWaitwait=newWebDriverWait(driver,29);

   wait.until(ExpectedConditions.alertIsPresent());

   Alertalert=driver.switchTo().alert();

   alert.accept();

   System.out.println("alert was present and accepted");

}

catch(Exceptione){

   System.out.println("alert was not present");

   System.out.print(e);

 

}

}

 


A
Ashish Thakur Replied on 03/06/2020

Use simple pause - life thread.sleep

Also send your project in attachment


K
Khushali Prabhubhai Patel Replied on 04/06/2020

LeadTest.Java 


K
Khushali Prabhubhai Patel Replied on 04/06/2020

Ingnore above file and consider attched project


Related Posts