There is a span with alt-text that will be displayed on hover. I’m trying to simulate a hover over this and trying to retreive the text that appeares on hover. This is the element.
<span aria-label-{"batman"} className="tooltip">
<img src-(Nocheck) alt-"Non-check issuing branch" data-testid="non-check-issuing-branch">
</span>
I have tried the following script.
String script = "var event = new MouseEvent('mouseover', {" +
" 'view': window," +
" 'bubbles': true," +
" 'cancelable': true" +
"});" +
"arguments[0].dispatchEvent(event);";
((JavascriptExecutor) driver).executeScript(script, elementToHoverOver);
I have also tried using Actions to directly perform the hover action. None of them seem to work. This is the xpath of the element.
//span[@aria-label='batman']
Am I not accessing the right xpath for the hover? Any help is appreciated.