I'm using Selenium with Junit framework while testing a website https://fitnesaveikals.lv/ I ran into a problem this popup shows up (the popup is a temporary thing the messaging could change and be replaced with marketing popups). Is there a way to check if this popup is there/visible? When manually testing the page the popup dialog shows up once but when testing while using lambdatest it shows up in every test time meaning the tests fail.
Asked
Active
Viewed 615 times
0

Edijs Bergs
- 15
- 5
-
And also i need to close it so that the test could continue. – Edijs Bergs Oct 21 '21 at 10:28
-
Try to find it when opening your page, if it is there, select the close button and click it, if it is not displayed, juste resume your test. – Flav Oct 21 '21 at 10:36
-
Have you seen this question? https://stackoverflow.com/questions/19403949/how-to-handle-pop-up-in-selenium-webdriver-using-java – op_ Oct 21 '21 at 11:28
-
`driver.findElement(By.className("mfp-close").click()` – pburgr Oct 21 '21 at 13:42
1 Answers
0
You should do try catch function to identify, no inbuild methods in selenium,
if it is there, it will close the pop up.
try{
driver.findElement(By.className("mfp-close")).click();
}catch (Exception ex){
system.out.println("pop is not displaying");
}

Jayanth Bala
- 758
- 1
- 5
- 11