Selenium web driver does not select a value in drop down

38 views
Skip to first unread message

reidm...@gmail.com

unread,
Aug 2, 2017, 4:55:06 PM8/2/17
to Selenium Users
Hello,

Method:

  public ss selectType(String Type){
   
WebElement myElement = driver.findElement(By.xpath ("//select[@data-val-required='Type is Required.']"));
   
Select dropdown= new Select(myElement);
   dropdown
.selectByVisibleText(Type);
       
System.out.println("Select type" + Type);
   
return this;
 
}

@Test

  selectSRype("Enroll");


When I run my test, it should select the value Enroll from the drop down field. But it does not. I also don't get any error. It did print the message in console too. During run, I can see field is being clicked by value is not being selected.  How can I select a value from drop down field?


Please advise.


poobathy r

unread,
Aug 2, 2017, 10:39:21 PM8/2/17
to seleniu...@googlegroups.com
Please use selectbyvalue or selectbyoption

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b7f0dabd-d110-4552-bc3d-f85b274b64d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nitish Kumar

unread,
Aug 13, 2017, 9:22:29 AM8/13/17
to Selenium Users
If would be helpful if you could share the html code of your dropdown.
Reply all
Reply to author
Forward
0 new messages