title: Unable to Handle Ajax Pop up in Selenium WebDriver
body: <p>I'm new in Selenium. I'm trying to make Script in selenium of MacDonald's login and Order.But After login I'm unable to click Continue and any other option please help me.</p>
  
  <p>my code is:--</p>
  
  <pre><code>WebDriver selenium= new FirefoxDriver();
  selenium.manage().window().maximize();
  
  String baseurl = "http://www.mcdelivery.co.in/";
  selenium.get(baseurl);
  
  Thread.sleep(2000); 
  Thread.sleep(5000);
  
  WebElement loginbtn = selenium.findElement(By.id("lnkBtnLogin"));
  if(loginbtn.isDisplayed()) {
      loginbtn.click();
  }
  
  WebElement username = selenium.findElement(By.id("txtMobileNumber"));
  if(username.isDisplayed()) {
      username.clear();
      username.sendKeys("******");
  }
  
  WebElement pwd = selenium.findElement(By.id("txtMsgPwd"));
  if(pwd.isDisplayed()) {
      pwd.sendKeys("******");
  }
  
  WebElement submit = selenium.findElement(By.id("btnSubmit"));
  if(submit.isDisplayed()) {
      submit.click(); 
      //Alert aler = selenium.switchTo().alert().accept();
      selenium.switchTo().activeElement();         
  }
  
  WebElement conti = selenium.findElement(By.id("btnContinue"));
  if(conti.isDisplayed()) {
      conti.click();
  }
  
  // selenium.close();
  </code></pre>
  
  <p>After running this I'm Getting Error </p>
  
  <pre><code>Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: 
  {"method":"id","selector":"btnContinue"}
  Command duration or timeout: 31 milliseconds
  </code></pre>