I have a UI tests run by Java code. One of the test casess happening for Apple Safari Browser. Is there any way to handle one time system alert from code side?
Asked
Active
Viewed 91 times
0
-
can you show alert code ? – Amit Jain Feb 19 '19 at 08:49
-
I actually dont have the code since I could not find a way to make this work.. From IOS perspective i was able to handle it for mobile devices system alert but from java ui test side i do not know actually how can i handle it. Any idea? @AmitJain – dicle Feb 19 '19 at 10:15
-
It is a web application btw not for mobile. @AmitJain – dicle Feb 19 '19 at 10:31
-
1You can try following Alert interface provided by selenium `import org.openqa.selenium.Alert; Alert alert = driver.switchTo().alert(); alert.accept();` – Amit Jain Feb 19 '19 at 13:11
-
If the alert belongs to OS, it's unreachable by selenium. In such cases you have to avoid the alert. – pburgr Feb 20 '19 at 07:39
-
You mean i can not handle OS system alert from selenium for apple safari? @pburgr – dicle Feb 20 '19 at 10:21
-
Yes. And it is not quiestion of browser or OS. If would be possible to reach system dialog from browser (from selenium) it would be great security issue. – pburgr Feb 20 '19 at 11:58
-
So how developers should handle system alert then when we do web site ui testing.. One time system alert appear always.. Is there a way to dismiss it somehow? @pburgr – dicle Feb 21 '19 at 08:17
-
I don't think so. In my scenarios I had same problem. Solved with avoiding the alerts File download dialog by setting browser not to ask, p12 auth. dialog as well in browser settings importing p12 file and again setting not to ask. No always possible in all browsers. I use selenium to smoke tests. Tests in specific browsers are usualy targeting an small test cases which I do manualy. – pburgr Feb 21 '19 at 11:15
-
Did you face the problem for apple safari as well? @pburgr – dicle Feb 21 '19 at 15:41
-
I meant safari alert btw not OS actually. System Alert from Safari itself like letting some sites to do somethings or some other similar alerts we faces.. @pburgr – dicle Feb 21 '19 at 15:43
-
I run my test suite on windows, secondary on linux. If the alert in safari belongs to safari, it should be interactable. Please post your code and it's failure. – pburgr Feb 21 '19 at 16:24