0

I have the situation where I need to create some automatic actions with selenium on a third party website (which I assume means that I can't use the highcharts api).

When the third party website is loaded, there is no tooltip element in the html body. It seems that it is dynamically added when the cursor is hovering over the chart.

I would like to for the tooltip to be shown via java selenium. If there is a javascript way to do this please let me know and I will try to transfer it to the selenium code myself

So far I have tried via the browser console with javascript to trigger a 'mouseover' event or to add a 'hover' class to different elements inside the highcharts container but I had no luck, the tooltip is not added to the html body and therefore I cannot select it.

I believe the above issue can be reproduced with the element with highcharts-tooltip class is not added to the html body until the user hovers on the chart.

Feedbacker
  • 890
  • 6
  • 17
  • Have you tried `visibilityOfElement` or `presenceOfElement`? – Nandan A Nov 26 '21 at 12:55
  • 1
    My problem is that the tooltip element is not visible. In fact it's not even added to the DOM. My problem is that I can't find a way to trigger the condition so that the tooltip is added to the DOM. – Feedbacker Nov 26 '21 at 13:05
  • See https://stackoverflow.com/questions/69035370/i-need-to-read-the-text-with-the-tooltip-ive-tried-a-lot-of-ways-and-i-always/69040660#69040660 – pburgr Nov 26 '21 at 13:49
  • @pburgr Thank you but my problem is that I cannot programmatically trigger a hover event so that the tooltip element is added in the DOM in the first place. This probably has to do with the highcharts framework and what conditions it needs to show the tooltip – Feedbacker Nov 26 '21 at 13:57

1 Answers1

1

You should be able to get global Highcharts variable and call onMouseOver method on a specific point.

Highcharts.charts[0].series[0].points[0].onMouseOver();

You can also dispatch mousemove event directly on a svg element.

document.getElementsByClassName('highcharts-point')[0].dispatchEvent(new Event('mousemove', { 'bubbles': true }));

API Reference: https://api.highcharts.com/class-reference/Highcharts.Point#onMouseOver

ppotaczek
  • 36,341
  • 2
  • 14
  • 24
  • I couldn't access the global `Highcharts` variable. However, using a `mouseover` event on the point did the trick, thank you! – Feedbacker Nov 29 '21 at 09:07