How to do mouse hover using Selenium WebDriver in Firefox 19?

后端 未结 6 703
梦谈多话
梦谈多话 2020-12-14 10:14

I have used selenium 2.31.

I have used Actions class for mouse movement. Using this I moved the mouse over a menu and its submenu appeared only for a fraction of se

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 10:31

    Try this code... It's c sharp code...

    //Webelement is the main menu Link
    webElement = driver.FindElement(By.XPath("Your element xpath"));
    Actions act = new Actions(driver);
            act.MoveToElement(webElement).Perform();//This opens menu list
    
            System.Threading.Thread.Sleep(5000);//This line will help you to hold menu 
     //This web element is the sub menu which is under main menu
            webElement = driver.FindElement(By.XPath("Sub menu path"));
            act.MoveToElement(webElement).Perform();//This opens menu list
            System.Threading.Thread.Sleep(5000);//Holds menu
        //This web element is the option you have to click
            webElement = driver.FindElement(By.XPath("Path"));
            webElement.Click();
    

提交回复
热议问题