Verifying text of a child object

Hi all, apologies if this has been covered before, but is there a way to verify text of an object that is a child of the one being identified?

I have a series of clickable areas (I’ll call them ‘widgets’), all identifiable with a unique ID, and within each one is an icon and a text label.

I’d like to…if possible…check that the text (e.g. “Widget 1 Label”) is contained ‘within’ the widget (and only by identifying the widget, not the ‘child’ text label).

Any help greatly appreciated - thanks :slight_smile:

Sounds like a job for WebUI.getText()

Well, you’re first (today) :wink:

Hi Russ, thanks so much for your help - your solution worked.

In case this is useful for any other noobs out there like me, I combined the getText with a verifyMatch command to have the check done all in one step…

WebUI.verifyMatch(mainObjectLabel, WebUI.getText(findTestObject(‘Main Object’)),
false, FailureHandling.CONTINUE_ON_FAILURE)

Thanks Russ :slight_smile:

1 Like

This year even :smiley:

1 Like

Hi Russ, whilst this has been working well for Chrome, I’ve noticed that when I run mobile emulation within Chrome (using Custom Desired Capabilities), the text inside an object is no longer captured.

Do you have any ideas why this might be the case?

Is the text visible?

Yes, the text is visible when executing the test in Chrome, AND in mobile emulation (custom capabilities) mode - thanks.

If this is reproducible for more than one field on a single page, it might be a bug. In which case…

Repost this as a bug (we’re polluting your original thread here). Make sure you add copious notes, steps, screenshots, etc.

Post it here:

Thanks Russ, much appreciated - I’ll check I can reproduce it for other items and if so I will report it as a bug as soon as I’m able to :slight_smile:

1 Like

Just to conclude this post, I determined that I didn’t think this was a bug.

I don’t quite understand why it was returning an empty string, rather than failing to find the object, but I’ve managed to resolve the issue by using a variety of ‘wait’ commands which seems to have made the test more robust (I’m verifying items on a ‘carousel’, not all of which is on screen at any one time).

1 Like