TextValue variable doesn't always work for QT fields
TextValue variable doesn't always work for QT fields
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.
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.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
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).
To add something to a InputField, use
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
To solve your problem, that the value sometimes is null and sometimes it is"", use
Best Regards,
Martin
Ranorex Support Team
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}");
Code: Select all
repo.yourInputField.PressKeys("YourText");
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)
Code: Select all
if ((repo.yourInputField.TextValue == null) || (repo.yourInputField.TextValue == ""))
Martin
Ranorex Support Team
Re: TextValue variable doesn't always work for QT fields
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?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
Hi,
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
We improve our technologies per release, but currently there a no special QT support improvements.StevenR wrote: Will there be better QT support in the future?
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
Re: TextValue variable doesn't always work for QT fields
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!
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!
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
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
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
Re: TextValue variable doesn't always work for QT fields
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.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
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
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
Re: TextValue variable doesn't always work for QT fields
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.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
Thanks it advance!Ok, I will make one and post it here as soon as I am finished.
Regards,
Markus
Ranorex Support Team
Re: TextValue variable doesn't always work for QT fields
I have created the demo app that shows many of the issues I have been experiencing with QT elements.
You do not have the required permissions to view the files attached to this post.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
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
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
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
Hi Steven,
I analyzed the sample app you provided and here are my findings:
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
I analyzed the sample app you provided and here are my findings:
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":StevenR wrote:When fields are empty sometimes instead of having the empty string value "" it is set to null.
string text = textElement.TextValue ?? string.empty;
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: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
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:Press and Focus methods do not work, have to work around by using the slower and less robust Click method
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:Tons of issues, the only way to reliably navigate them is to hard-code in PressKeys methods with the text of the desired option
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:Check and Uncheck methods do not work, have to use PressKeys("{Space}") or if that doesn't work, use the Click method again
Like with the combobox list, "Select" does not work correctly, but calling "Focus" selects a tree item.StevenR wrote:Cannot focus or select tree items, have to use Click method
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
Re: TextValue variable doesn't always work for QT fields
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.
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.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: TextValue variable doesn't always work for QT fields
Hi Steven,
I hope the following code snipplet will help you. Create a user code action within your recording and use this code
Regards,
Martin
Ranorex Support Team
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);
}
}
Martin
Ranorex Support Team