title: Unexpected alert open chrome driver
body: <p>I am trying to get text from an alert which has been opened and closed respectively.</p>
  
  <p>I am using ChromeDriver for automation.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>System.out.println("Requesting to be Share as Only");
  WebElement lnkShare = driver.findElement(By.xpath("//*[@id='lnkRequest']"));
  ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", lnkShare);
  lnkShare.click();
  wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='lnkShare']")));
  driver.findElement(By.xpath("//*[@id='lnkShare']")).click();
  wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[@id='ctl00_Dashboard_ucProgressbar_imgLoader']")));
  driver.switchTo().frame("fbContent");
  driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_rdoRequestShareOnly']")).click();
  driver.switchTo().alert().accept();
  String alertText = alert.getText();
  driver.switchTo().alert().accept();
  System.out.println("getting in if loop");
  
  if (alertText.contains("Net Size/Gross Size")) {
      System.out.println("Present");
  } else {
      System.out.println("not");
  }
  
  System.out.println("out of loop");But I get the following error :
  </code></pre>
  
  <blockquote>
    <p>org.openqa.selenium.UnhandledAlertException: unexpected alert open:
    {Alert text : Error detected when attemption to Share! The following
    fields are missing: Net Size/Gross Size Vendor Please confirm and try
    again.}</p>
  </blockquote>
  
  <p>Where is the issue?</p>