Tuesday, 21 July 2015

How get selected option/name text from dropdown

//Scenario: Want to get the selected option from dropdown

String selectedOption = new Select(d.findElement(By.xpath("//*[@id='cstate']"))).getFirstSelectedOption().getText();
System.out.println("Selected state is :" + selectedOption);
Assert.assertEquals("ASSAM", selectedOption);

Output: It verifys whether the selected option is 'assam' or not.

No comments:

Post a Comment