title: Selenium Webdriver unable to get elements in Modal
body: <p>I am writing a Selenium Webdriver script that is supposed to click on a Link and then this Modal Window pops up.</p>
  
  <p><a href="https://i.stack.imgur.com/IAzcv.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/IAzcv.jpg" alt="Modal Window on the page"></a></p>
  
  <p>When I try to access card number field (//input[@id=pan]), I get No such element found exception <code>org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"pan"}</code></p>
  
  <p><a href="https://i.stack.imgur.com/s8BIE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/s8BIE.png" alt="Input control I want to get hold of"></a></p>
  
  <p>This is the code I have tried with no luck:</p>
  
  <pre><code>WebElement modal = driver.findElement(By.xpath("//div[@class='ute-pay-now-modalContent']"));
  driver.switchTo().frame(modal);
  WebElement el =  driver.findElement(By.xpath("//input[@id='pan']"));
  </code></pre>
  
  <p>Also tried this:</p>
  
  <pre><code>WebElement modal = driver.findElement(By.className("ute-pay-now-modalContent"));
  driver.switchTo().frame(modal);
  WebElement el =  driver.findElement(By.xpath("//input[@id='pan']"));
  </code></pre>
  
  <p>Also tried this:</p>
  
  <pre><code>WebDriverWait block = new WebDriverWait(driver,10);
  WebElement modal = block.until(ExpectedConditions.visibilityOfElementLocated(By.className("ute-pay-now-modalContent")));
  WebElement pan;
  pan    = modal.findElement(By.id("pan"));
  </code></pre>
  
  <p>Also tried this:</p>
  
  <pre><code>driver.switchTo().defaultContent();
  </code></pre>
  
  <p>Also tried this:</p>
  
  <pre><code>driver.switchTo().activeElement();
  </code></pre>
  
  <p>Can someone please help suggest me how to resolve this issue?</p>