static dropdown
- works only for dropdowns having web element with select as tagName.
WebElement staticdropdown = driver.findElement(By.id(""));
Select dropdown = new Select(staticdropdown);
dropdown.selectByIndex(3);
dropdown.selectByValue("XYZ");
dropdown.selectByVisibleText("XYZ");
dropdown.getFirstSelectedOption().getText()
dynamic dropdown
// parent - child relationship xpath; comment one of the two
Here one location can be in both From and TO dropdowns so we need to consider the From and TO Weblocators as parents and then
add the location as child.
Example below:
driver.findElement(By.xpath("//div[@id='ctl00_mainContent_ddl_originStation1_CTNR'] //a[@value='BLR']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//div[@id='ctl00_mainContent_ddl_destinationStation1_CTNR'] //a[@value='MAA']")).click();
ctl00_mainContent_ddl_originStation1_CTNR - From locaton dropdown
ctl00_mainContent_ddl_destinationStation1_CTNR - To location dropdown
No comments:
Post a Comment