TextValue variable doesn't always work for QT fields

Class library usage, coding and language questions.
StevenR
Posts: 7
Joined: Wed Nov 30, 2011 10:38 pm
Contact:

TextValue variable doesn't always work for QT fields

Post by StevenR » Wed Nov 30, 2011 10:53 pm

Hello, I am using Ranorex to make automated tests and have run into issues when working with software that uses the QT framework. I did copy the plugins folder and created the qt.conf file so everything mostly works but there is still a lot of Ranorex functionality that does not work as expected.

One thing in particular that's giving me trouble right now is the TextValue variable in Ranorex text field objects. It does not always contain the value of the field and I encounter Ranorex.SetAttributeFailedException errors when I try to set it to something manually. When fields are empty sometimes instead of having the empty string value "" it is set to null. I did not have this issue when testing non-QT user interfaces. Am I doing something wrong? Is this a bug in Ranorex?

I am using version 3.1.1.14266 on Windows 7 x64.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Thu Dec 01, 2011 1:11 pm

Hello,

Unfortunately with QT there are some limitations - one of them is the TextValue. It is not possible to write the TextValue Attribute, either a value nor a empty string.

But there is a workaround, using the PressKeys method, which is simulating key sequences.
For clearing a Inputfield, use the following code (simulating Strg+A and Backspace).

Code: Select all

repo.yourInputField.PressKeys("{LControlKey down}{Akey}{LControlKey up}{Back}");
To add something to a InputField, use

Code: Select all

repo.yourInputField.PressKeys("YourText");
Note, that "YourText" will be appended to the string which is already in your inputfield.

After clearing the values of the inputfield with the code line above, you can check the empty inputfield with

Code: Select all

if (repo.yourInputField.TextValue == null)
To solve your problem, that the value sometimes is null and sometimes it is"", use

Code: Select all

if ((repo.yourInputField.TextValue == null) || (repo.yourInputField.TextValue == ""))
Best Regards,
Martin
Ranorex Support Team
.
Image

StevenR
Posts: 7
Joined: Wed Nov 30, 2011 10:38 pm
Contact:

Re: TextValue variable doesn't always work for QT fields

Post by StevenR » Thu Dec 01, 2011 10:04 pm

Ah ok, thanks. I was using the PressKeys method as a workaround but I was wondering if I was just doing something wrong in getting it to play nice with QT. Will there be better QT support in the future?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Fri Dec 02, 2011 10:54 am

Hi,
StevenR wrote: Will there be better QT support in the future?
We improve our technologies per release, but currently there a no special QT support improvements.
Do you have a special case for QT? If yes please post us this case and we will try to fix it with one of the next releases.

Regards,
Peter
Ranorex Team
.
Image

StevenR
Posts: 7
Joined: Wed Nov 30, 2011 10:38 pm
Contact:

Re: TextValue variable doesn't always work for QT fields

Post by StevenR » Tue Dec 06, 2011 2:21 am

That would be most excellent. Most of our software is switching over to using QT for the user interface. I have been running into many other issues using QT.
Tables:
- If the table has a scroll bar ranorex can only see the elements that are visible
- If the table has a scroll bar ranorex cannot determine the actual number of elements in the table
- Sometimes tables change their ranorex path depending on whether they have filled cells or are empty
Buttons:
- Press and Focus methods do not work, have to work around by using the slower and less robust Click method
Combobox/Drop down Menus:
- Tons of issues, the only way to reliably navigate them is to hard-code in PressKeys methods with the text of the desired option
Checkboxes:
- Check and Uncheck methods do not work, have to use PressKeys("{Space}") or if that doesn't work, use the Click method again
Tree Menus:
- Cannot focus or select tree items, have to use Click method

Thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Tue Dec 06, 2011 11:12 am

Hi,

Thank you for the issues. I will add a bug to our internal bug tracking system.
Would it be possible to send us your application as reference for our tests?

Regards,
Peter
Ranorex Team
.
Image

StevenR
Posts: 7
Joined: Wed Nov 30, 2011 10:38 pm
Contact:

Re: TextValue variable doesn't always work for QT fields

Post by StevenR » Tue Dec 06, 2011 8:33 pm

I'm afraid not, our software has too much stuff in it that's export controlled or requires a security clearance to see. I may be able to whip up a sample application with some of the QT UI elements I've been having trouble with if you like or you could use the ones included with QT.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Wed Dec 07, 2011 1:07 pm

Hi,

it would be the best way (for both sides) if you set up a sample application for us.
With the sample application we can work on our QT plugin to deal with your components.

Best Regards,
Martin
Ranorex Support Team
.
Image

StevenR
Posts: 7
Joined: Wed Nov 30, 2011 10:38 pm
Contact:

Re: TextValue variable doesn't always work for QT fields

Post by StevenR » Thu Dec 08, 2011 6:50 pm

Ok, I will make one and post it here as soon as I am finished. It may be awhile before I can do it as I have other higher priority things I am working on too right now.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Fri Dec 09, 2011 12:58 pm

Ok, I will make one and post it here as soon as I am finished.
Thanks it advance!

Regards,
Markus
Ranorex Support Team
.
Image

StevenR
Posts: 7
Joined: Wed Nov 30, 2011 10:38 pm
Contact:

Re: TextValue variable doesn't always work for QT fields

Post by StevenR » Mon Dec 19, 2011 7:47 pm

I have created the demo app that shows many of the issues I have been experiencing with QT elements.
Attachments
TestApp.zip
(4.77 MiB) Downloaded 200 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Tue Dec 20, 2011 7:02 am

Hi,

Thank you for your demo app.

We will have a look on it with our developers and give you information about it asap.

Best Regards,
Martin
Ranorex Support Team
.
Image

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Thu Dec 22, 2011 10:02 am

Hi Steven,

I analyzed the sample app you provided and here are my findings:
StevenR wrote:When fields are empty sometimes instead of having the empty string value "" it is set to null.
That is correct. Please, check for "null" and the empty string as proposed by Martin or use the "??" operator which replaces a value if it is "null":
string text = textElement.TextValue ?? string.empty;
StevenR wrote:If the table has a scroll bar ranorex can only see the elements that are visible
If the table has a scroll bar ranorex cannot determine the actual number of elements in the table
That depends on the MSAA implementation of the control. It seems that for performance reasons this QT control only generates MSAA elements for the visible table entries. And Ranorex depends on these MSAA elements to recognize elements within the table. So unfortunately, there is nothing we can do from our side to fix this. However, as a workaround, you can always select the last item in the list, causing another item to spawn, thereby scrolling down the list. Or you can invoke "Press" on the scrollbar down button.
StevenR wrote:Press and Focus methods do not work, have to work around by using the slower and less robust Click method
I could not reproduce that issue. Invoking "Press" does work on the "Clear" button in your sample. However, you might still want to use the "Click" method, since it better reflects the user-perspective testing approach. ("Press" uses internal methods a human user could never invoke.)
StevenR wrote:Tons of issues, the only way to reliably navigate them is to hard-code in PressKeys methods with the text of the desired option
Another can't reproduce. If the combobox drop-down list is open (you can invoke "Press" on the combobox button), calling "Focus" on a list element successfully selects the list element. (Weirdly, "Select" does not work, but that's another issue of the QT MSAA implementation.)
StevenR wrote:Check and Uncheck methods do not work, have to use PressKeys("{Space}") or if that doesn't work, use the Click method again
Setting the "Checked" property works with your sample. However, if the application does not react quick enough, an exception might be thrown by Ranorex. We will fix that fix one of our next service releases.
StevenR wrote:Cannot focus or select tree items, have to use Click method
Like with the combobox list, "Select" does not work correctly, but calling "Focus" selects a tree item.

We will fix the issue with the ComboBox.Checked property sometimes throwing an exception. For all other issues we cannot provide a fix, since the recognition depends on the QT MSAA implementation, or could not reproduce the problem.
Please, feel free to comment on all my findings.

Regards,
Alex
Ranorex Team
.
Image

StevenR
Posts: 7
Joined: Wed Nov 30, 2011 10:38 pm
Contact:

Re: TextValue variable doesn't always work for QT fields

Post by StevenR » Thu Dec 22, 2011 6:46 pm

Thank you, that helps some. I will have to investigate what, if anything, the developers did differently on the buttons that did not press and other functionality that was not reproduced with this demo app.

For the combobox, how are you getting the list of items in it? If I just look at the Items variable of the combobox I either get an empty list if the drop down button was not pressed, or it was pressed I get a list of visible elements only and that list is also duplicated.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TextValue variable doesn't always work for QT fields

Post by Support Team » Fri Dec 23, 2011 11:45 am

Hi Steven,

I hope the following code snipplet will help you. Create a user code action within your recording and use this code

Code: Select all

public void iterateItem()
        {
        	
        	var buttonOpen = repo.FormDialog.ButtonOpen;///form[@title='Dialog']/element[@class='QWidget' and @instance='5']/combobox/button[@accessiblename='Open']
        	buttonOpen.Click();
        	
        	var list = repo.List;///form[@title='test']/element/element[@class='QWidget' and @instance='0']/list
        	                     /// 
        	foreach (ListItem item in list.FindChildren<ListItem>())
        	{
        		Report.Screenshot(item);
        	
        	}

        }
Regards,
Martin
Ranorex Support Team
.
Image