Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Mouse hover action selenium webdriver

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 657
    Comment on it

    To perform mouse hover function over a main menu which has sub elements, for this we have to chain all the actions that we want to achieve in one go.


    • In order to perform it, first move on to the main menu element which has sub elements and click on the new option.


    • To achieve mouse hover action we use 'Action' API constructor with 'moveToElement' method;


    1. Launch the site URL(

    2. Mouse hover over a main menu(nerd digest)

    3. Now find out the hidden element which will only  be visible on mouse hover

    4. Click on new option or sub menu item(.net)


    Sample code:-

    import java.util.concurrent.TimeUnit;
           import org.openqa.selenium.*;
           import org.openqa.selenium.interactions.Actions;
    	public class mouseHoverAction{
       	public static void main(String[] args) {
            driver = new FirefoxDriver();
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
            WebElement mainmenu = driver.findElement(By.xPath(".//*[@id='offshoreindialive']/div[9]/ul/li[10]/a"));
            Actions action = new Actions(driver);


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: