Q:

How to handle hidden webelement in selenium webdriver with java

My Html
<div id="example-1-tab-1" class="responsive-tabs-panel" style="display: block;">
  <div class="freme_box">
   <iframe class="demo-frame" src="dropdown/default.html">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
     <body>
      <select>
         <option selected="" value="">Please Select</option>
         <option value="Afghanistan">Afghanistan</option>
         <option value="Albania">Albania</option>
      </select>
     </body>
    </html>
   </iframe>
  </div>

I want to select the value from dropdown list and i have already use select method but it doesn't work. Getting :

Element not found Exception.

Not sure how to handle this element which is not visible. Any Help? 

A:

Actually select element is inside an iframe as it seeing in the provided HTML, so you need to switch that iframe first before find select element as below :-
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe.demo-frame")));

//Now find the dropdown 
Select select = new Select(driver.findElement(By.tagName("select"));

select.selectByVisibleText("Afghanistan");

