Page 1 of 1

How to get only the partially visible text?

Posted: Fri Apr 11, 2014 9:45 am
by boby
Hi,

Sometimes the text for a UI element is not completely visible, for instance, this one,
excel.PNG
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

Re: How to get only the partially visible text?

Posted: Mon Apr 14, 2014 8:38 am
by mzperix
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

Re: How to get only the partially visible text?

Posted: Tue Apr 15, 2014 8:38 am
by boby
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

Re: How to get only the partially visible text?

Posted: Tue Apr 15, 2014 9:07 am
by mzperix
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

Re: How to get only the partially visible text?

Posted: Tue Apr 15, 2014 1:48 pm
by boby
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

Re: How to get only the partially visible text?

Posted: Tue Apr 15, 2014 2:01 pm
by boby
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