简体   繁体   中英

How to find elements in a drop-down menu wrapped inside <li>, <a> and >ul> tags in Selenium Webdriver using Java

I'm new to Selenium and needs help with finding the xpath of particular tag to get it clicked.

I want to click SOQL Query link from the highlighted drop-down menu as given in below image:

在此处输入图片说明

This is the code what i have tried so far :

//hovering

 WebDriverWait wait = new WebDriverWait(driver,20);

 //First click on dropdown down to open options
 wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("li.top > a.top_link"))).click();

//Now select opened option
wait.until(ExpectedConditions.elementToBeClickable(By.linkText("a[href*='query.php']"))).click();

Use the Action class to handle such menu click

WebElement queriesLink = driver.findElement(By.cssSelector("li.top > a.top_link"));

WebElement soqlQueryLink = driver.findElement(By.xpath("//li/a[contains(.,'SOQL Query')]"));

Actions action = new Actions(driver);
action.moveToElement(queriesLink ).clickAndHold(soqlQueryLink ).click().build().perform();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM