Quality Testing

Quality is delighting customers

Hi Guys,

Is there any way to get window title with making any switch in selenium?

presently I'm using below code:

String currentWindow = driver.getWindowHandle();
Set<String> availableWindows = driver.getWindowHandles();
if (!availableWindows.isEmpty())
{
for (String windowId : availableWindows) {

String wintitle=driver.switchTo().window(windowId).getTitle();
if ((wintitle.equals(title))||(wintitle.contains(title)))
{
return true;
} else {
driver.switchTo().window(currentWindow);
}
}
}
return false;

Thanks in advance.

Thanks,

Jitendra Jangid

Views: 618

Reply to This

Replies to This Discussion

We can not get the window title without moving focus to particular window using Selenium.

Ok, this is not possible. 

One small question: Does driver.getWindowHandles() return all window handler in sequence in which they appear on page (hierarchy)?

Not Sure. 

but, you can switch between windows without knowing the name. Refer below link for further assistance with new window handling. 

http://santoshsarmajv.blogspot.in/2012/04/how-to-switch-control-to-...

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service