3

My issue is that there are some tooltips with help text. When the mouse is moved over the tooltip, some help text appears as shown in the picture. In the previous iterations I used the following code to validate the text which worked perfectly. But its not working anymore now in the new version of the webpage.

Thanks for your support

${helpText} set Variable    (Optional) Please enter any additional information about this sample 
Mouse over  ${Tooltip}  
Wait Until Page Contains    ${helpText} 5s

enter image description here

<a href="#" data-toggle="tooltip" title="(Optional) Please enter any additional information about this sample">
                                            <i class="fa fa-question-circle" aria-hidden="true"></i></a>

UPDATE

I am actually able to validate the tooltip comments in some cases, but found that the tooltip attribute was not "Title", but "data-original-title". When the html code is written like the following, the test passes:

<a href="#" data-toggle="tooltip" title="" data-original-title="(Required) Please enter the legal first name">
      <i class="fa fa-question-circle" aria-hidden="true"></i>
        </a>

Difference is when the Title attribute is straightforward like my first example, the test fails. But in cases, where the data-original-title attribute is used, the test passes.

nhrcpt
  • 862
  • 3
  • 21
  • 51
  • What does "not working anymore" mean? Are you getting an error? – Bryan Oakley Sep 27 '17 at 11:12
  • Well, I have used the same code for an earlier version of the site, and I could successfully validate it on that site using the "Wait until page Contains" keyword. But It is not working on the new version of the site – nhrcpt Sep 27 '17 at 17:38
  • So, was it timing out? Throwing an error? Finding the text even though it wasn't there? ... Just saying "it used to work but now it doesn't" isn't very useful. We need to know specifically what the new behavior is. – Bryan Oakley Sep 27 '17 at 18:30
  • Hi, actually as you can see from the screenshot, the text is visible. but RF is throwing error that the text is not visible. – nhrcpt Sep 27 '17 at 18:31
  • Well, the code you're showing is looking for "some help text", but that string does not appear in the screenshot. You've giving us misleading information. Also, most browsers delay for a second or two before showing the tooltip -- are you waiting for the tooltip to show up? – Bryan Oakley Sep 27 '17 at 18:32
  • My apologies. I am editing the text in the code. – nhrcpt Sep 27 '17 at 18:34
  • we can't see your code, we can only see what you post in the question. – Bryan Oakley Sep 27 '17 at 18:35
  • Yes, The question is updated – nhrcpt Sep 27 '17 at 18:37
  • Are you certain this used to work, and that the page hasn't changed? AFAIK, `Wait until page contains` only ever worked for text, and not for attributes of an element. When you say "previous iterations", what was being iterated over? Previous versions of the page? Previous versions of browsers? – Bryan Oakley Sep 27 '17 at 19:40
  • Hi Bryan, Thanks for your interest. My previous iterations I mean the previous versions of the website that I am testing. I have tested the texts in older versions using this keyword and successfully validated the texts. I am actually planning to reinstall the the old version for re-testing and will share my findings here once done. – nhrcpt Sep 28 '17 at 17:30
  • Hi Brian, I have edited the post with my findings . RF can actually validate the tooltip texts, but it depends on the Title Attribute coding. – nhrcpt Oct 02 '17 at 22:12

1 Answers1

4

As you can see from the attached html source, the tooltip text is usually in the title attribute of the element (in a more fancy UI framework it might be in a separate element - to allow formatting etc, that's shown through js on mouse over; but that's not the case here).

So in order to validate it, you should get the attribute value and compare; e.g.:

${locator}=      Set Variable    xpath=//a[@data-toggle="tooltip"]    # this is NOT a good locator - but can't think of a better one with the provided source
${the tooltip}=  Get Element Attribute    ${locator}@title   # after the @ you specify the name of the target attribute - title in this case

Should Contain   ${the tooltip}     (Optional) Please enter    # any text validation you need happens here
Todor Minakov
  • 19,097
  • 3
  • 55
  • 60
  • Thanks. I am actually doing it now, which validates that the text conforms with the requirement. But I need to do something to validate that the text is actually visible when the mouse is over the tooltip. – nhrcpt Sep 27 '17 at 17:40
  • 1
    @nhrcpt: are you _certain_ you need to test that? I think it's a reasonable assumption that if you use standard element attributes that the browser will do what it's designed to do. Of course, if you have your own custom javascript that causes the tooltip to appear, then that's something worth testing. – Bryan Oakley Sep 27 '17 at 18:31
  • 2
    If the tooltip is in the title attribute, you have to jump through quite some hoops *not* to display it - [like this](https://stackoverflow.com/questions/15364063/is-it-possible-to-hide-the-title-from-a-link-with-css). And if that is so, that's obviously a deliberate decision/requirement, outside of the scope "how to verify the tooltip text is this" - more in the "no tooltips should be displayed" realm. – Todor Minakov Sep 27 '17 at 19:41