//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);
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