title: Selenium code for how to handle frame and multiple popup windows on the same web page?
body: <p>I am doing my work on java Selenium WebDriver. I want to  handle frame and multiple popup windows on the same web page?</p>
  
  <p>I have done with handle the frame and going back to default Content. Now I am facing problem in handle multiple popup windows on the same web page? </p>
  
  <p>I have tried with following methods:</p>
  
  <pre><code>//First method
  
  WebDriverWait wait =   new WebDriverWait(driver, 20);
  wait.until(ExpectedConditions.elementToBeClickable(By.id("masterPOP")));
  driver.findElement(By.id("close-popup")).click();
  
  //Another method
  
  Alert alert = driver.switchTo().alert();
  alert.dismiss();
  
  //I am sharing my code below:
  
  package BRA_product;
  
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  
  public class frameeeeeee {
  
      public static void main(String[] args) throws InterruptedException {
  
          String exePathGecko=("C:\\Users\\Prerna\\Downloads\\geckodriver.exe");
          System.setProperty("webdriver.gecko.driver",exePathGecko);
  
        WebDriver driver=new FirefoxDriver();
         //Zivame home page
       driver.get("http://www.zivame.com/#?");
  
       //switch to frame
         driver.switchTo().frame("webpush-bubble"); 
         driver.findElement(By.xpath(".//*[@id='deny']")).click();
         //back to home page
         driver.switchTo().defaultContent();
  
         //login to zivame 
         driver.findElement(By.xpath("//a[@href='#myaccount']")).click();
  
         driver.findElement(By.xpath("//*[@id='auth-email']")).sendKeys("test890@gmail.com");
  
         driver.findElement(By.xpath(".//*[@id='auth-password']")).sendKeys("test123");
  
  
         driver.findElement(By.xpath(".//*[@id='authForm']/div[3]/button")).click();
  
  
  
         //Thread.sleep(3000);
  
         driver.quit();
  
      }
  
  }
  </code></pre>
  
  <p><strong>EDIT:</strong>
  Error which i got is:</p>
  
  <pre><code>Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[@id='auth-email']  
  </code></pre>
  
  <p>I am getting this error because not able to close two popup on the same page. popup id is :<code>&lt;id=materPOP&gt;</code> and
  <code>&lt;p id ="close-pop"&gt;</code>. </p>
  
  <p>Another popup id details are: <code>&lt;div class="wrapper"&gt;</code> and <code>&lt;div id ="webklipper-publisher-widget-container-notification-close-d‌​iv" class="close"&gt;</code>  </p>