I am using geb spock and trying to hover an element, however I am getting error. Below are details. Page Object Class
class HomePage extends Page {
static at ={
title.contains("Activity Dashboard")
}
static content = {
tabConnections (wait : true) {$("a", "class" : contains("dropdown-toggle"), "text" : "Connections")}
subMenuManageConnections (wait: true) {tabConnections.find("ul").find("a" , "href": "/managecash/EDGE_Network" , "text" : "Manage Connections")}
}
public void mouseHoverMethod(){
waitFor {tabConnections.displayed}
Actions actions = new Actions(driver)
actions.moveToElement(tabConnections).build().perform()
}
}
When I am calling mouseHoverMethod method from my spock spec file, getting below error message:
on line (actions.moveToElement(tabConnections).build().perform()
) as below:
Error Message:
groovy.lang.MissingMethodException: No signature of method: org.openqa.selenium.interactions.Actions.moveToElement() is applicable for argument types: (geb.content.TemplateDerivedPageContent) values: [pageobjects.general.HomePage -> tabConnections: geb.navigator.NonEmptyNavigator] Possible solutions: moveToElement(org.openqa.selenium.WebElement), moveToElement(org.openqa.selenium.WebElement, int, int)
Can you please help me how mouse hovering can be done in Geb Spock?
@kriegaex, @erdi. Thanks for your solutions. I am also able to find one working solution and created below methods in page object. All three methods are working fine.
public void mouseHoverMethodOne (TemplateDerivedPageContent element){
waitFor {element}
element.jquery.mouseover()
element.click()
}
public void mouseHoverMethodTwo (TemplateDerivedPageContent element){
waitFor {element.displayed}
Actions actions = new Actions(driver)
actions.moveToElement(element.firstElement()).build().perform()
element.click()
}
public void mouseHoverMethodThree (TemplateDerivedPageContent element){
waitFor {element.displayed}
interact {
moveToElement(element)
}
element.click()
}
Thanks for your help on this. I have rated your answers too, as those give me lot of insights.