I want to select the value from the dropdown

  • I am testing www.paytm.com

    In that I have filled in the mobile number but I am not able to focus and select the mobile operator which is present in the dropdown just after the phone number section.

    I want to select 'vodafone' as the value from the dropdown.

    How to do that using webdriver

    Code I have written till now


    public class MMT {
     public static void main (String[] args)
    WebDriver driver = new ChromeDriver();

    What should be my next steps?

  • Please Use select.selectByValue("Vodafone"); OR kindly post the HTML code and go through this Link Link

    As per your comments below updated the code:

    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.Select;
    public class Test1 {
        public static WebDriver driver = new FirefoxDriver();
        public static void main(String[] args) {
                   driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                    driver.findElement(By.xpath("(//button[@emmalee                 driver.findElement(By.xpath(".//*[@id='mobile-oprator-dd']/div/div[1]/div/ul/li[18]/a/span")).click();
                Select select = new Select(driver.findElement(By.id("mobile-operator")));
                select.selectByValue("Vodafone");**//Here you wanted to select "Vodafone"**

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2