1. How to Switch from one frame to another
// How to Switch from one frame to another
WebElement iFrmeElement = driver.findElement(By.xpath("xPath for Frame"));
driver.switchTo().frame(frameElement);
//Or
driver.switchTo().frame(id or name)
//Or
driver.switchTo().frame(index of frame)
2. We can switch to default again by:
driver.switchTo().defaultContent();
3. We can switch to a window based on name, Id or Windows handle
driver.switchTo().window("windowName");
4. We can switch to an alert
Alert alert = driver.switchTo().alert();
// We can close an alert using methods for alert object
alert. accept();