How to mouseover on a webelement using Selenium WebDriver with Java

后端 未结 3 1201
醉酒成梦
醉酒成梦 2021-01-14 22:57

How to perform a mouse hover functionality using Selenium Webdriver?

Test Case is like say, open Yahoo site and there is link (Mail) beside Sign-In. Upon mouse hover

相关标签:
3条回答
  • 2021-01-14 23:29

    I have used similar code and it works for me. I have also used the following at a few places: browser.executeScript("jQuery('mycss-selector').mouseover();") You will have to use css-selector, instead of xpath.

    0 讨论(0)
  • 2021-01-14 23:35
    Actions actions = new Actions(driver);
    actions.moveToElement(element).click().build().perform();
    
    0 讨论(0)
  • 2021-01-14 23:48

    Try this code:

    //Assume driver initialized properly.
    WebElement element = driver.findElement(By.id("Element id"));
    Locatable hoverItem = (Locatable) element;
    Mouse mouse = ((HasInputDevices) driver).getMouse();
    mouse.mouseMove(hoverItem.getCoordinates());
    
    0 讨论(0)
提交回复
热议问题