I am new to selenium and i would like to perform a simple task I want to select a drop-down from a tab and i have used \"http://www.spicejet.com/\" as an Reference. There is
Its not a dropdown. It a menu, You can use Actions
class to select the sub-menu you want. use below code :
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.id("highlight-addons"))).clickAndHold(driver.findElement(By.xpath("//li/a[contains(text(),'SpiceMax')]"))).click().build().perform();
To select a value from the DropDown
, you have to first Mouse Hover
the WebElement
ADD-ONS
, then to select SpiceClub Membership Offer
you can use the following code block :
WebElement elem = driver.findElement(By.xpath("//a[@id='highlight-addons']"));
Actions action = new Actions(driver);
action.moveToElement(elem).perform();
List<WebElement> items = driver.findElements(By.xpath("//ul[@class='add-ons-tab']/li/a"));
for(WebElement myitem:items)
{
if(myitem.getAttribute("innerHTML").contains("Membership"))
{
myitem.click();
break;
}
}