//Scenario: If assam option is available in dropdown then select the value.
public void verifySeletedDDValue()
{
d.get("https:/oaa.onlinesbi.com/oao/onlineaccapp.htm");
d.manage().timeouts().implicitlyWait(150, TimeUnit.SECONDS);
//clicking on apply now button
d.findElement(By.xpath("//*[@id='btnApply']/a/img")).click();
d.findElement(By.xpath("//a[text()='Start New']")).click();
//for get default text fron text field
String defaultTxt =d.findElement(By.xpath("//*[@id='firstName']")).getAttribute("value");
System.out.println("printing default text on text filed :" +defaultTxt);
//working fine
String allStates=d.findElement(By.xpath("//*[@id='cstate']")).getText();
System.out.println("all options from dropdown :" + allStates);
WebElement select=d.findElement(By.xpath("//*[@id='cstate']"));
List<WebElement> options = select.findElements(By.tagName("option"));
System.out.println("all options are :" + options);
for (WebElement option : options) {
if("ASSAM".equals(option.getText()))
option.click();
}
output: it will search for 'Assam' and it selects the ''assam"
No comments:
Post a Comment