Mouse hover issue


#1

I want to mouse over on a dynamic object

below is my code — which is throwing exception unable to mouse over the element

WebElement element = WebUiCommonHelper.findWebElement(findTestObject('MyObjects/FirstGraph'), 30)

WebUI.executeJavaScript('arguments[0].scrollIntoView(true);', Arrays.asList(element))

WebDriver driver = DriverFactory.getWebDriver()

List<WebElement> allSections = driver.findElements(By.xpath(graph))


int noOfSections = allSections.size()

println(noOfSections)

	for (def index : (1..noOfSections)){
    try {
        String section = '(//*[@class="highcharts-series highcharts-tracker"])[1]/*['+index+']'
		
		 println (section)
        new_btn = WebUI.modifyObjectProperty(findTestObject('Object Repository/MyObjects/section'), 'xpath', 'equals', section,  false)
		WebUI.mouseOver(new_btn);
        WebUI.delay(2)

            
    }

    catch (Exception e) {
        e.printStackTrace()
    } 
    
    String data1 = '(//*[@class="highcharts-tooltip"])[1]/*[5]/*'

    
    List<WebElement> datas = driver.findElements(By.xpath(data1))

   
	for (def j : (1..datas.size())){
        WebUI.delay(3)

       
         String xpath = '((//*[@class="highcharts-tooltip"])[1]/*[5]/*)['+j+']'
       
        eachSec = WebUI.modifyObjectProperty(findTestObject('Object Repository/MyObjects/eachSec'), 'xpath', 'equals', xpath,  false)
		String values = WebUI.getText(eachSec)
        KeywordUtil.logInfo(values)

        print(values)
        WebUI.delay(3)
    }
    println('')


#2

Try this instead:

import org.openqa.selenium.By
import org.openqa.selenium.WebElement
import org.openqa.selenium.interactions.Actions

WebDriver driver = DriverFactory.getWebDriver();
WebElement section = driver.findElement(By.xpath("(//*[@class='highcharts-series highcharts-tracker'])[1]/*["+index+"])");
Actions action = new Actions(driver);
action.moveToElement(section).perform();

#3

Tried this as well, but no luck


#4

Can you share the whole error log?


#5

com.kms.katalon.core.exception.StepFailedException: Unable to move mouse over object ‘Object Repository/MyObjects/section’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.mouseOver(MouseOverKeyword.groovy:90)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.execute(MouseOverKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.mouseOver(WebUiBuiltInKeywords.groovy:776)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$mouseOver$3.call(Unknown Source)
at LinearFlow.run(LinearFlow:99)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:331)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:322)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:301)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:293)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:227)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1553231868835.run(TempTestCase1553231868835.groovy:21)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/MyObjects/section’ located by 'By.xpath: ’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1053)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword$_mouseOver_closure1.doCall(MouseOverKeyword.groovy:80)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword$_mouseOver_closure1.call(MouseOverKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.mouseOver(MouseOverKeyword.groovy:90)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.execute(MouseOverKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.mouseOver(WebUiBuiltInKeywords.groovy:776)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$mouseOver$3.call(Unknown Source)
at Script1552580813922.run(Script1552580813922.groovy:99)


#6

the same logic with the same xpath is working fine using selenium


#7

It cannot be hovered over because it cannot find the element in the first place:

Please check your Test Object and ensure that you have the correct xpath, and that the “Detect object by?” column is checked.


#8

I don’t think the xpath value is wrong as the same xpath and logic works with Java-Selenium with Ecliipse IDE

if you have observed the below code I am modifying objects dynamically and hovering on the section

String section = ‘(//[@class=“highcharts-series highcharts-tracker”])[1]/[’+index+’]’

	 println (section)
    **new_btn = WebUI.modifyObjectProperty(findTestObject('Object Repository/MyObjects/section'), 'xpath', 'equals', section,  false)**
	WebUI.mouseOver(new_btn);

I suspect the failure is in highlighted line
any help is really appriciated
Thanks


#9

You can test your xpath in the browser inspector by putting this into the console:

$x("(//*[@class="highcharts-series highcharts-tracker"])[1]/*[1]")


#10

yes this also worked. the exception thrown was wrong I guess


#11

I have same issue with my script. I just wanted to mouse over and select an option from the drop down, but the mouse over is not working.

05-30-2019 03:35:01 PM mouseOver(findTestObject(“Page_Luma/li_Registered Note”))

Elapsed time: 31.489s

Unable to move mouse over object ‘Object Repository/Page_Luma/li_Registered Note’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to move mouse over object ‘Object Repository/Page_Luma/li_Registered Note’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.mouseOver(MouseOverKeyword.groovy:90)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.execute(MouseOverKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.mouseOver(WebUiBuiltInKeywords.groovy:776)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$mouseOver$4.call(Unknown Source)
at New Request.run(New Request:53)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:336)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:327)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:306)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:232)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:129)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:112)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:81)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1559244858863.run(TempTestSuite1559244858863.groovy:35)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Luma/li_Registered Note’ located by 'By.xpath: //li[@id = ‘select2-registrationType-result-lwsw-2’ and @title = ‘Registered Note’ and (text() = ’
Registered Note
’ or . = ’
Registered Note
‘)]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1097)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword$_mouseOver_closure1.doCall(MouseOverKeyword.groovy:80)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword$_mouseOver_closure1.call(MouseOverKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.mouseOver(MouseOverKeyword.groovy:90)
at com.kms.katalon.core.webui.keyword.builtin.MouseOverKeyword.execute(MouseOverKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.mouseOver(WebUiBuiltInKeywords.groovy:776)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$mouseOver$4.call(Unknown Source)
at Script1557341246409.run(Script1557341246409.groovy:53)
… 13 more
)

Any help is really appreciated


#12

You should be able to reduce that xpath down to just the @id part - once you have an ID, everything else is just noise. (If not, the page is broke/invalid HTML).


#13

If the target element is rendered dynamically, you should wait for it to appear before you move mouse over it.

def testObject = findTestObject('Object Repository/Page_Luma/li_Registered Note’)
// let's wait for the dynamic element to appear
def found = WebUI.waitForElementPresent(testObject, 10)
if (found) {
    WebUI.mouseOver(testObject)
    ...
} else {
    WebUI.comment("${testObject} is not present")
}


#14

I am facing same issue but it showing object is hovered but in the UI it was not hovered and hovered element not interactable while try to click…
Plz help on this …?

16:42:00.394
PASSED
Object: ‘Object Repository/Page_Schedules/test_obj’ is hovered

16:42:00.787
FAILED
Unable to click on object ‘’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:86)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$3.call(Unknown Source)
at schedules.Template.clickOnScheduleTempCellAndAddAssignmnet(Template.groovy:79)
at schedules.Template.invokeMethod(Template.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at tc_fillTheTemplate.run(tc_fillTheTemplate:20)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:169)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:142)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:91)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1568113879513.run(TempTestSuite1568113879513.groovy:35)
Caused by: org.openqa.selenium.ElementNotInteractableException: element not interactable
(Session info: chrome=76.0.3809.132)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘CSI-SAJJAATH’, ip: ‘192.168.2.24’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 76.0.3809.132, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce…, userDataDir: C:\Users\MOHAME~1\AppData\L…}, goog:chromeOptions: {debuggerAddress: localhost:62804}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 0c40f22a6e7e5c22490b3bbe8bd6fa01
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:20)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:79)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.call(ClickKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:86)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$3.call(Unknown Source)
at schedules.Template.clickOnScheduleTempCellAndAddAssignmnet(Template.groovy:79)
at schedules.Template.invokeMethod(Template.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at Script1568098647151.run(Script1568098647151.groovy:20)
… 13 more
)


#15

The message tells the reason:

The XPath expression is over-specific. I suppose you can simplify/shorten the XPath expression.

You have not showed your target HTML, therefore I can not find the answer…

Howerver, I can guess, the following XPath expression would be worth trying:

//li[@id = ‘select2-registrationType-result-lwsw-2’]