How to get only the partially visible text?

Class library usage, coding and language questions.
boby
Posts: 9
Joined: Fri Apr 11, 2014 9:35 am

How to get only the partially visible text?

Post by boby » Fri Apr 11, 2014 9:45 am

Hi,

Sometimes the text for a UI element is not completely visible, for instance, this one,
excel.PNG
excel.PNG (5.41 KiB) Viewed 1462 times
the text of the first cell is only partially visible, in this case "hello my fr" but not the whole text "hello my frieds".

Now the question is: how can I get only the partially visible text but not the whole text? The Text property for a UI element returns always the whole text, I think.

Thank you!
Bo

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: How to get only the partially visible text?

Post by mzperix » Mon Apr 14, 2014 8:38 am

Hi boby,

I would compute the width of the string in pixels, and compare with the cells witdth.

Can you explain your problem in more detail? Maybe we can figure out a better solution to the problem, than computing the width of a string in pixels :)

For example if goal is to make the text always visible, then you can make a double click on the border of the column header, and it will automatically set it's width to proper size. No need to look for partial text.

Kind Regards,
Zoltán Major

boby
Posts: 9
Joined: Fri Apr 11, 2014 9:35 am

Re: How to get only the partially visible text?

Post by boby » Tue Apr 15, 2014 8:38 am

Hi,

thanks for your reply.

We intend to detect whether the text on a UI control is cut or not. Sometimes we have the problem that some text on our UI, e.g. button, label, etc., are partially visible, because the width of the UI element is not enough. It's not necessary an Excel cell, and the Excel example I have given is only used to explain the problem. Our application is indeed based on WPF. At moment we cannot figure out a solution with Ranorex.

Thank you and best regards,
Bo

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: How to get only the partially visible text?

Post by mzperix » Tue Apr 15, 2014 9:07 am

Hi boby,

Well, there is the image based automation path, but I think since the elements that's text is overlapped are dinamically created, there is no way to create a baseline image to make the comparison.

Well I would go on the calculating path. I found some relevant informations on calculating string width in WPF: http://stackoverflow.com/questions/6525 ... -of-string

And from this forum I found a link to FormattedText class: http://msdn.microsoft.com/en-us/library ... dtext.aspx With this class, you can compute the string's width in pixels from Ranorex. After you get the width, you can compare the container element's width with the strings's computed width.

Is this a solution for you?

PS: there is a not too elegant one: Ranorex can make screenshots of every element, and put it in the report. You can make some screenshots of every new window, and someone will sweep through them after finishing the testcase :)

Best regards,
Zoltán

boby
Posts: 9
Joined: Fri Apr 11, 2014 9:35 am

Re: How to get only the partially visible text?

Post by boby » Tue Apr 15, 2014 1:48 pm

Hi Zoltan,

your solution looks quite well and I will try it. As there's no native support from Ranorex for this issue, I think your proposal could be a solution for it. Thank you!

Kind regards,
Bo

boby
Posts: 9
Joined: Fri Apr 11, 2014 9:35 am

Re: How to get only the partially visible text?

Post by boby » Tue Apr 15, 2014 2:01 pm

Hi Zoltan,

by the way, how would you "compute the string's width in pixels from Ranorex" ? Have you any code example?

Thank you!

Best regards,
Bo