Ask a Question

Is there a way to see if a text is trimmed?

els
Occasional Contributor

Is there a way to see if a text is trimmed?

I'm working on a test looking to check if the text shown is trimmed. Essentially say you have a text that says "Hello World! This is a small world!", based on the width allowed in that window the user will only see "Hello World! This is..." and I'm trying to check for that, but I don't see any properties for that or any possible functions.

 

Thank you.

3 REPLIES 3
tristaanogre
Esteemed Contributor

There's not a built in function for doing so, no.  Typically, it's not really a "property" or such that's detectable.

 

You can check the properties of the object to look for the truncated text and use that property.  Then use the aqString.Find method to check for "...".  If it finds it, it's truncated.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
els
Occasional Contributor

Hi. Thank you for your swift response. I imagined I could do it that way, but scanning through the text object properties, I would expect to use the Text property or perhaps the WPFControlText property in order to "grab" string value and I was hoping the ellipses (...) would be included in those properties, but sadly that's not the case.

 

In every text property, I get the entire string and not the trimmed string so it's been confusing on how to test against that. I do have a TextTrimming property but it just states what type of trimming is used and not if that text is actually trimmed. 

tristaanogre
Esteemed Contributor

It MIGHT be something in the general rendering in the browser or application.  Not a property of the object itself but how the technology acts by default.  I've seen some applications where, if the field is not wide enough, the text does NOT get trimmed but you have to scroll right (take a long URL in the address bar of your favorite browser for instance).

 

So, this might not be something you can detect by the text of the text field/label itself.  Maybe it's a "native" object property.  It's probably going to take some investiation.

 

The alternative is to do an image capture and OCR but I typically don't like those methods.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: