I have a small baggage icon which when hover the mouse over the icon, a tooltip text displays. I want to test this by writing C# code in Visual Studio.
Here is how the baggage icon displayed in html:
<div class="icon_png information icon_baggageyes" title="1 piece included in this fare."></div>
And here is my code to test the tooltip:
Actions a = new Actions(driver);
IWebElement tooTipObject = driver.FindElement(By.XPath("//div[@class='icon_png information icon_baggageyes']"));
a.MoveToElement(tooTipObject).Click().Build().Perform();
The problem is when I debug step by step the code above, the tooltip text will show up. But when I run the test, the tooltip text does now show.
By searching on the internet, some people say the reason is the mouse does not focus on the baggage icon long enough time for the tooltip text to display.
But how to resolve this problem? I have been searching for solutions but could not find one that works for mine.
And another question is my code: a.MoveToElement(tooTipObject).Click().Build().Perform();
the tooltip text will only show if I put .Click() in this code. But I am testing the mouse hover over function, should not be clicking on the icon. This is so weird.