How to verify a tooptip which ist hidden in a div-section?

Hello,

I’m trying to verify a tooltip in an Angular website. Its not possible to acess this tooltip with the Object Spy.

The tooltip is created via a message-name.

The following part contains the reference to the message --> “cdk-describedby-message-15”

<a class="id_link_label_linkvalue ng-star-inserted" rel="noreferrer" target="_blank" aria-describedby="cdk-describedby-message-15" cdk-describedby-host="" href="https://abcdefg.xy">II/2 </a>

At the end of the DOM there ist a DIV-section with the text of the message named cdk-describedby-message-15.

<div id="cdk-describedby-message-container" aria-hidden="true" style="display:
none;">
<div id="cdk-describedby-message-0">Drucken</div>
<div id="cdk-describedby-message-15">Freigabe am: 26.08.2016</div>
<div id="cdk-describedby-message-16">Finalisierung am: 26.09.2016</div>
</div>

In my testcase I pick up the message name sucessfully via getAttribute

String msgName = WebUI.getAttribute(findTestObject('Institutsanzeige/FKRPGesamtnote/BBk1'), 'aria-describedby')

In the repository I’ve defined a dummy-object ToolTip1 with object property xpath equals //*[@id="${msgTT}"]

In my testcase I replace the parameter with the message name “cdk-describedby-message-15”

The verifyElementPresent was sucessful

WebUI.verifyElementPresent(findTestObject('Institutsanzeige/FKRPGesamtnote/ToolTip1', [('msgTT') : msgName]), 3)
10-15-2018 10:21:41 AM - [START]  - Start action : verifyElementPresent
10-15-2018 10:21:41 AM - [INFO]   - Finding Test Object with id 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1'
10-15-2018 10:21:41 AM - [INFO]   - Checking object
10-15-2018 10:21:41 AM - [INFO]   - Checking timeout
10-15-2018 10:21:41 AM - [INFO]   - Finding web element with id: 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1' located by 'By.xpath: //*[@id="cdk-describedby-message-15"]' in '3' second(s)
10-15-2018 10:21:41 AM - [INFO]   - Found 1 web elements with id: 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1' located by 'By.xpath: //*[@id="cdk-describedby-message-15"]' in '3' second(s)
10-15-2018 10:21:41 AM - [PASSED] - Object 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1' is present
10-15-2018 10:21:41 AM - [END]    - End action : verifyElementPresent

Attention! Forum software does not show the whole xpath expression.

But if I try to access the message-text its empty

println(WebUI.getText(findTestObject('Institutsanzeige/FKRPGesamtnote/ToolTip1', [('msgTT') : msgName])))
10-15-2018 10:21:41 AM - [INFO]   - Finding web element with id: 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1' located by 'By.xpath: //*[@id="cdk-describedby-message-15"]' in '15' second(s)
10-15-2018 10:21:41 AM - [INFO]   - Found 1 web elements with id: 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1' located by 'By.xpath: //*[@id="cdk-describedby-message-15"]' in '15' second(s)
10-15-2018 10:21:41 AM - [INFO]   - Getting text of object 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1'
10-15-2018 10:21:41 AM - [PASSED] - Text of object 'Object Repository/Institutsanzeige/FKRPGesamtnote/ToolTip1' is: ''

I’ve also tried two other approaches wich I found in the forum and they are basically working but none of them gives me the messagetext if I use getText.

String newXpath = ('//*[@id="' + msgName) + '"]' 
TestObject new_TT = WebUI.modifyObjectProperty(findTestObject('Institutsanzeige/FKRPGesamtnote/ToolTip1'), 'xpath', 'equals', newXpath, true)
 
TestObject dynamicObject = new TestObject('dynamicObject').addProperty('xpath', com.kms.katalon.core.testobject.ConditionType.EQUALS, 
            newXpath, true)

Has anyone a hint?

try following on your invisible div:

println WebUI.getAttribute(TO,'textContent')
1 Like

Thanks a lot Andrej! It works. So easy if one knows where to search.

welcome

Hi Andrej,
I am getting message as NULL. My tooltip xpath is
note icon

I have created testobject “tooltip_ETS” with the xpath "(//div[text()= " ETS “]//following::img[@mattooltipposition=“above”])[1]” for the above.

* NOT accepting WCCP Chassis * Evergreen chassis should not be dropped at any facility other than Everport * Evergreen export reefer container with Evergreen genset chassis: If not delivering to ETS, have the terminal flip reefer and return genset chassis to ETS

I tried code like below but it has returned NULL
String tt = WebUI.getAttribute(findTestObject(“Object Repository/PORTS/ControlTower/ReturnSignal/tooltip_ETS”), ‘textContent’)
println("tt is: " + tt)
Please help me.
Thanks,Dayakar

Hello,
do you get any error?

If you know how to look at the HTML, then you can check which attribute has the text that you are looking for. (For Chrome, hit F12 then right click on the element and select Inspect).

Maybe like:
String tt = WebUI.getAttribute(findTestObject("PORTS/ControlTower/ReturnSignal/tooltip_ETS"), 'title')
WebUI.comment("Tool tip info is ${tt}")
println("tt is: " + tt)

I’m not a great proponent of using arrays as the xpath (only my personal experience). They just seem to get broken with every other release we have. Can you try to find a “safer” path?

I didn’t get any error but returned NULL.

Thanks,
Dayakar

I inspected the XPATH but it does not have attribute title.

/html/body/app-root/app-member-frame/div/div[2]/div[2]/app-empty-returns-page/div/div/app-empty-returns/div/app-empty-returns-items/div/div[10]/div/div/div[1]/img
Element is:
note icon