How can I get text value from bs-tooltip-container

Following is the script i have tried:

WebUI.mouseOver(findTestObject(‘Object Repository/Page_SDS Wind-Log/div_Total Power Lost_pieContainer’))
attribute = WebUI.getAttribute(findTestObject(‘Object Repository/Page_SDS Wind-Log/div_Total Power Lost_pieContainer’),
‘style’)
println(attribute)

It returns blank value when 'style is used and it returns ‘null’ value when class attribute is used.

@Team: Could you please look into it and help me resolve this issue or provide an input on which attribute to use in order to fetch text after mouse over.

Thanks.

Sorry, but I find your question quite confusing. I am going to show you how to retrieve the innerText from the <bs-tooltip-container> element even though your screenshot shows the <canvas> element is selected.

To retrieve the innerText of any HTML element, use WebUI.getText()

Thank you for your reply. I tried using WebUI.getText() but it gives blank value.

@technoglobalinc Please don’t send me login details via private message. I will not login in to a secure site unless the login is made public.

What I need from you:

I need to see the text you are trying to retrieve. Do another screenshot and make sure you highlight the text you are trying to reach.

Thanks.

I want to fetch the value of tooltip(26%) of the piechart. Could you please help with it.

Also, I have shared two screenshots to show effects of mouse over and without.

I guess you’re not understanding me.

Here is the relevant part of your screenshot. You highlighted a comment. I think I need to see the element I circled in red. Click that little arrow. If there are more elements inside, keep opening them until we find your target with “26%”.

image

If you can’t find it, then we’re looking at the wrong element.

The moment cursor is moved out of pie chart, the circled element which you have asked for vanishes. Therefore, i am not able open it till the last element.

I need to see a lot more HTML - the complete path to the tooltip element when the chart is hovered.

And by the way, my solution will be JavaScript + CSS. If you don’t like that idea, you should say so now.

I managed to drill down to the value. Please check.

Is there any method using which i can fetch tooltip-inner value.

Yes. More than one. Your issue is going to be ensuring only the target tooltip is visible and present in the DOM. If you use your hover code, I’m hoping we have covered that potential issue.

The screenshot you provided did not cover the complete path to the tooltip. In fact, it contains LESS html.

Even so, let’s give this a shot: Add this code to your test case AFTER you have positioned the mouse. Make sure also the tooltip is visible BEFORE this code is executed…

String js = '''
var selector = "bs-tooltip-container div.tooltip-inner";
return document.querySelector(selector).innerText;
'''
String text = WebUI.executeJavaScript(js, null)

println("The tooltip text is: " + text)

Your script works perfectly fine. Thank you.

Could you please throw some more light on it??

Mouseover code:
WebUI.mouseOver(findTestObject(‘Object Repository/Page_SDS Wind-Log/div_Total Power Lost_pieSlice1’))

Which object shall I use in findTestObject.

Thanks

My code does not use a Test Object. That is what I meant when I said…

Yeah thank you Russ, got it.

Really appreciate your time and help.

1 Like

A post was split to a new topic: Retrieving values from Custom HTML Elements