I am testing a web application eCommerce site. When I select three items to remove from compare list, it will display the alert pop message, then I use alert class and accept the pop up and other scenarios, but my code is not handling alert pop up, and it will close the driver. Here is my code, not working

2 Answers
2

You are either trying to access an element that the FirefoxDriver can't reach to because the modal dialogue is still active or (looking at the log) you are clicking "Ok/Done/Finished/Whatever" on the modal dialogue without selecting the required number of products.

Since you didn't provide much information about what you're testing, I'd have to conclude that your site is popping up a modal dialogue box that reads "Please retain at least 2 products to compare." Under what conditions does your site do that? Have you accidentally triggered them? Are you controlling for how many options are on the compare site so that when you remove the three options, there are still at least 2 left? It seems like you're comparing 4 options and trying to remove 3 of them. You should confirm that the application is working according to spec; again, it seems like it's popping up an error message, which, if it should be doing that, you should be verifying.

In other words, it sounds like this test case has some serious issues and should be re-examined at an abstract level, not just the test code.