How to handle Select in Selenium


Example of using Select in Selenium 

public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("https://www.mobikwik.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@id='mobile_number']")).sendKeys("9910979218");
driver.findElement(By.xpath("//*[@id='mobile_amount']")).sendKeys("10");
WebElement operator = driver.findElement(By.xpath("//*[@id='mobile_operator']"));
Select option = new Select(operator);
option.selectByVisibleText("Idea");
Thread.sleep(5000);
driver.close();
}