In some cases we would be in a circumstance to choose at least two things in a rundown box or content region. To comprehend the equivalent, we would exhibit different determination from the rundown utilizing 'https://demos.devexpress.com/aspxeditorsdemos/ListEditors/MultiSelect.aspx'.
Example
Allow us to state, we need to choose 3 things from this rundown as demonstrated as follows -
Let us perceive how to code for this usefulness −
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.interactions.Action;
public class webdriverdemo {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.navigate().to("http://demos.devexpress.com/aspxeditorsdemos/ListEditors/MultiSelect.aspx");
//driver.manage().window().maximize();
driver.findElement(By.id("ContentHolder_lbSelectionMode_I")).click();
driver.findElement(By.id("ContentHolder_lbSelectionMode_DDD_L_LBI1T0")).click();
Thread.sleep(5000);
// Perform Multiple Select
Actions builder = new Actions(driver);
WebElement select = driver.findElement(By.id("ContentHolder_lbFeatures_LBT"));
List<WebElement> options = select.findElements(By.tagName("td"));
System.out.println(options.size());
Action multipleSelect =
builder.keyDown(Keys.CONTROL).click(options.get(2)).click(options.get(4)).click(options.get(6)).build();
multipleSelect.perform();
driver.close();
}
}
output
After executing the content, the things would be chosen as shown above and the size of the rundown box would likewise be imprinted in the reassure.