I am getting a pop up as displaying in the attached screen shot when i am accessin the site using IE.I have to click on ‘Show all Contents’ in the pop up to access the site further.Please give give input on how to handle this pop up

2 Answer(s)

Selenium Webdriver allows us to identify a pop up window by using its name attribute.

Save the Windowhandle of Parent browser window by using driver.getWindowHandle()

Then switch to the help popup browser window – driver.switchTo().window(“Window which has showall contents”)

Or use the following syntax

Set <String> windows = driver.getWindowHandles() and try to get the window which matches the title attribute of your window.

Hope this helps.

SD Train Answered on May 15, 2015.
Add Comment

In case there is no name attribute nor title get all the windowhandles

Set<String> windows = driver.getWindowHandles()
if(!windows.isEmpty())
{
for(String windowId:windows)
{
driver.switchTo().window(windowId);
if(driver.getPageSource().contains(“show all contents”))
{
//which ever button you want to click
button.click();
}
}
}

SD Train Answered on May 15, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.