0

am new to selenium and in my previous question Selenium IDE command for input type hidden it is using select2 please help me with the command to selection option for drop-down list.

i tried looking in here https://gist.github.com/3683275 but it doesn't seem to work for me

mouseDown('//a[@class="select2-choice select2-default"][1]')
mouseUp('//li[contains(@class,"select2-result")][1]')
Community
  • 1
  • 1
Venkatesh
  • 64
  • 2
  • 8

3 Answers3

1

These commands open the options list, wait for it to appear, and finally choose the option labelled "California". Select2 can be customized in different ways, hope these commands work for you.

mouseDown      css=.select2-choice > div > b
waitForVisible css=.select2-results
mouseUp        css=.select2-result-label:contains('California') 
Milanka
  • 1,742
  • 19
  • 15
0
WebElement element = driver.findElements(By.xpath(/*xpath*/));

Select select = new Select(element);

select.selectByVisibleText(value);
Sirko
  • 72,589
  • 19
  • 149
  • 183
Smita
  • 11
  • 1
  • thanks for your help but i am looking for selenese command to be used in Selenium IDE. Thanks – Venkatesh Jan 04 '13 at 11:28
  • its not suitable when it comes to the place of List based drop-down selection like this (mouseUp('//li[contains(@class,"select2-result")][1]')) – sathya Apr 08 '19 at 07:59
0

Alternatively, it can also be handled by using clickAt()

clickAt('//a[@class="select2-choice select2-default"][1]');
waitForVisible("css=.select2-results");
clickAt('//li[contains(@class,"select2-result")][1]');
jitendrapurohit
  • 9,435
  • 2
  • 28
  • 39