How to count the number of drop down value present in a drop down using selenium webdriver?

1,955 views
Skip to first unread message

Sudhansu Sekhar panda

unread,
Jan 21, 2013, 8:18:47 AM1/21/13
to seleniu...@googlegroups.com
Hi All,

How to count the number of drop down value present in a drop down using selenium webdriver? 

e.g. suppose there is a drop down and in that drop down there are 12 values.How to count the number of drop down values ?

Thanks
Sudhansu

Ramaguru N

unread,
Jan 21, 2013, 9:41:29 AM1/21/13
to seleniu...@googlegroups.com
Check with the below link.
Hope it will help.



Regards,
Ramaguru N 



Sudhansu

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/bJkoOFNOoOYJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

chaitanya

unread,
Jan 22, 2013, 1:31:28 AM1/22/13
to seleniu...@googlegroups.com
U can do like this shekhar..

 List<WebElement> dropdownvalues        =driver.findElements(By.xpath("path to dropdown/options"));
dropdownvalues.size() gives u the dropdown values count...

sandeepmoh...@gmail.com

unread,
Sep 28, 2013, 11:52:13 PM9/28/13
to seleniu...@googlegroups.com
Hi sudhansu,
 In my scenario Pick lists type is a button (Not select type)

1)int t=driver.findElements(By.xpath("//*[@id='industryButton']/span/button")).size();
        System.out.println("No of dropdown count"+t);       //Result 1

2)String u=driver.findElement(By.xpath("//*[@id='industryButton']/span/button")).getText();
        System.out.println("totals are:"+u); //Result = Select

Not showing lists of    values available in pick lists .eventhough tried for                
List<WebElement> dropdownvalues        =driver.findElements(By.
xpath("path to dropdown/options"));
dropdownvalues.size() 

can you plese let me know

url:http://my.monsterindia.com/create_account.html?r=1380418138
xpath=//*[@id='industryButton']/span/button

Regards,
sandeep
Reply all
Reply to author
Forward
0 new messages