Selenium Select2 command for drop-down box
Asked Answered
C

3

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]')
Culmination answered 5/12, 2012 at 17:6 Comment(0)
S
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') 
Sociolinguistics answered 22/1, 2013 at 13:43 Comment(0)
T
0
WebElement element = driver.findElements(By.xpath(/*xpath*/));

Select select = new Select(element);

select.selectByVisibleText(value);
Teatime answered 6/12, 2012 at 11:13 Comment(2)
thanks for your help but i am looking for selenese command to be used in Selenium IDE. ThanksCulmination
its not suitable when it comes to the place of List based drop-down selection like this (mouseUp('//li[contains(@class,"select2-result")][1]'))Feudist
S
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]');
Snowden answered 26/11, 2014 at 9:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.