Q.How to Handle DropDownMenu in Selenium?
- using ' moveToElement() ' method of Actions class.
Selenium Code
import javax.swing.Action;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class DropDownMenu
{
public static void main(String[] args)
{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.actimind.com");
WebElement menu=driver.findElement(By.xpath("//span[text()='About Company']"));
Actions actions=new Actions(driver);
actions.moveToElement(menu).perform();
driver.findElement(By.linkText("Basic Facts")).click();
}
}
Browser OUTPUT:

No comments:
Post a Comment