ServiceNow Interview Question

How to select a value from drop How to select multiple values in a drop down How to select all values in drop down

Interview Answers

Anonymous

May 7, 2021

check is the dd is multi selectable - if(select.isMultiple()) { //select.selectByValue("Jan"); //select.selectByValue("Feb"); } ---------------------- List options = select.getOptions();//gets all options for(WebElement el : options){ String temp = el.getText(); select.SelectByVisibleText(temp); } ----------------------------------- List options =select.getAllSelectedOptions() for (WebElement option : options) { System.out.println(option.getText()); -------- dropdown.deselectAll();

3

Anonymous

Jun 1, 2019

Select selectObject = new Select(element); if(selectObject.isMultiple()){ selectObject.selectByIndex(1); selectObject.selectByIndex(2); selectObject.selectByIndex(3); } You can also use: selectByVisibleText(String text) selectByValue(String text)

1