String strURL;
strURL="URL";
WebDriver firefoxDriver=new FirefoxDriver();
firefoxDriver.get(strURL);
WebElement list1;
list1=firefoxDriver.findElement(By.name("lst"));
List<WebElement> lstOptions=list1.findElements(By.tagName("option"));
list1.sendKeys(Keys.CONTROL);
lstOptions.get(0).click();//Selects the first option.
lstOptions.get(1).click();//Selects the second option.
I got the exact one after long search..
ReplyDeleteThanks a lot :)
WebElement list = driver.findElement(By.id("sel"));
ReplyDeleteList listOpts = list.findElements(By.tagName("option"));
int lastIndex = listOpts.size()-1;
Actions act = new Actions(driver);
act.clickAndHold(listOpts.get(0)).perform();
act.moveToElement(listOpts.get(lastIndex)).release().perform();
This worked for me.
Thanks for the help... It worked
ReplyDelete