Alter is not handled with Implicit wait

I tried the below sample given in your site as per the direction given by you. For Explicit wait it dismissing the alert but the i am unable to witness the alert it was too quick. Why is not working for implicit wait or thread.sleep() ?. I am getting no alert exception.  Can you help on this ?

Practice Exercise

1) Launch new Browser 2) Open URL “http://toolsqa.wpengine.com/automation-practice-switch-windows/” 3) Click on the Button “Timing Alert” 4) Accept the Alert (Alert will take 3 second to get displayed, Use WebDriverWait to wait for it)

Program:
 import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.support.ui.ExpectedConditions;
public class HandlingAltersandWindow {
public static void main(String[] args) throws InterruptedException { 
 WebDriver driver=new ChromeDriver(); driver.get(“http://toolsqa.com/automation-practice-switch-windows/“); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS); driver.findElement(By.xpath(“//button[text()=’Timing Alert’]”)).click(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Alert alert =driver.switchTo().alert();
System.out.println(alert.getText()); alert.accept(); driver.quit();
}
}
Default Asked on June 9, 2018 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.