Reputation: 245
When I click on a button on a page, a popup is displayed. This is not a windows popup. It is the application popup.. The popup I get in my application is similar to the one i have shown in the image with a X button. now How do I move the driver control to the popup and then click on the close button available on the popup and then move back my control back to the original page..
I have to do this using Selenium WebDriver and C#.
Upvotes: 0
Views: 17290
Reputation: 10329
The example you have shown is not a popup, but a simple DHTML window.
To access the X of the example you have provided, you could use: driver.findElementBy(By.id("profile-tooltip-closebtn")).click()
.
Upvotes: 0
Reputation: 1149
You need to do the following...
Here is the sample code in C#
foreach (string handle in browser.WindowHandles)
{
IWebDriver popup = driver.SwitchTo().Window(handle);
if (popup.Title.Contains("popup title"))
{
break;
}
}
IWebElement closeButton = driver.FindElement(By.Id("closeButton"));
closeButton.Click();
Upvotes: 4
Reputation: 529
The new pop message too have an id or class name..
First get the class name or id of that pop up and the go for the xpath(may be we will find class name) of the close button and click on it.
Upvotes: 0