How to close the popup dialog
I have an unexpected popup dialog “You get it first” to appear on the expedia.co.in. It blocks my test to enter departure date and time. I am unable to close this modal dialog by using the code below.
driver = new FirefoxDriver();
var popupDialog = Driver.Instance.FindElement(By.Id(“popupmodal”));
I have also tried to use the close but can’t get it close. Any suggestions?
The HTML tag of close button is this
Right now there is nothing other than href as an attribute to the anchor tag, I used to to identify it. Had there been a CSS or an ID I would have used it.
Thanks Rocky and Virender, Both solutions are working.
A question is why the locator needs to include the tag name ‘a’? I thought the classname ‘CloseBtn’ was unique on the popupmodal page.
Is it because it is a popup modal and treats differently.
Rocky – why do you use XPath to locate the element. I found it is difficult to understand. Would CSSSelector be better than XPath?