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)
     {
    
    System.setProperty("webdriver.chrome.driver","E:/som/chromedriver/chromedriver.exe");
    
    WebDriver driver = new ChromeDriver();
    
    driver.get("http://paytm.com");
    
    driver.findElement(By.id("mobile-number")).sendKeys("9876543212");`
    

    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.get("http://www.paytm.com");
                driver.manage().window().maximize();
                   driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
                  driver.findElement(By.id("mobile-number")).sendKeys("9876543212");
                    driver.findElement(By.xpath("(//button[@emmalee                 driver.findElement(By.xpath(".//*[@id='mobile-oprator-dd']/div/div[1]/div/ul/li[18]/a/span")).click();
                    driver.findElement(By.id("mobile-amount")).sendKeys("100");
                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