I am trying to use switch to alert and perform an action but i face error.
Now the real issue is when i put the below code in try,catch it works perfectly. i mean it handles the alert perfectly. But when i use the same without try, catch code it throws the below exception
Alert alert = driver.switchTo().alert();
String AlertText = alert.getText();
System.out.println(javascriptconfirm.getText());
alert.accept();
Please find the error below
No alert is present (WARNING: The server did not provide any stacktrace information)