Fill the form that contain the Choosen Drop-down and Select drop down.

59 views
Skip to first unread message

Prabhat Yadav

unread,
Mar 5, 2014, 3:50:31 AM3/5/14
to seleniu...@googlegroups.com
I am completely new to Selenium  and i got stuck on  drop down.  I want to fill complete form and submit it using selenium webdriver . but all the time i get stuck on drop-down of my web application.  i read so many question of it but really did not got any exact ans. may bw because i am not able to understand but still i want to know  what is the logic and concept of  it.

i used This example code to insert the value but i got -1 value.

WebElement select = uploadArticleDriver.findElement(By.tagName("select")); 
// select the web element that have tag name select  <<uploadArticleDriver>> is a webDriver instance variable.
List<WebElement> allOptions = select.findElements(By.tagName("option"));
// collect all the value/Webelement in to the object list name as allOptions  
for (WebElement option : allOptions) {
   System.out.println(String.format("Value is: %s", option.getAttribute("value")));
   option.click();
    }
//using for each  programmer  printing all the value of the webelement. 

Question: how to inset one value to drop down of the form.

Shailendra Bhadauria

unread,
Mar 5, 2014, 4:16:21 AM3/5/14
to seleniu...@googlegroups.com
Hi Prabhat,

you can fulfill you request by doing this.

<html>
<body>
<select id = "designation">
<option value = "MD">MD</option>
<option value = "prog"> Programmer </option>
<option value = "CEO"> CEO </option>
</option>
</select>
<body>
</html>

Now to identify dropdown do

Select dropdown = new Select(driver.findElement(By.id("designation")));



--
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-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/edd02e51-f9cd-4af0-8c12-7fce4a8a3408%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Thanks & Regards
Shailendra Singh Bhadauria
Email: shailendra...@gmail.com

Prabhat Yadav

unread,
Mar 5, 2014, 4:36:55 AM3/5/14
to seleniu...@googlegroups.com
Thanks shailendra, and how i inset value programmer in that drop down. 

Prabhat Yadav

unread,
Mar 5, 2014, 4:47:52 AM3/5/14
to seleniu...@googlegroups.com
NOT able to insert the desirable value in the drop down using it.


On Wednesday, March 5, 2014 2:20:31 PM UTC+5:30, Prabhat Yadav wrote:

Prabhat Yadav

unread,
Mar 5, 2014, 6:54:13 AM3/5/14
to seleniu...@googlegroups.com
Thanks shailendra ,  for the simple drop down (select -option ) by using method
 dropdown.selectByValue("prog"); //dropdown is the variable of the Select Class.
 dropdown.selectByVisibleText("Programmer");
 by using these Two method. now i can insert the any value of my choice in Drop down.  


NOw  Choosen, please suggest me some idea about choosen. How i can use the insert value in the choosen ????  


On Wednesday, March 5, 2014 2:20:31 PM UTC+5:30, Prabhat Yadav wrote:
Reply all
Reply to author
Forward
0 new messages