About identifying QT dialogs

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
theselby
Posts: 8
Joined: Wed Sep 26, 2018 12:28 pm

About identifying QT dialogs

Post by theselby » Thu Sep 27, 2018 1:26 pm

Hello,

I've run into weird scenarios trying to figure out how to automate a QT app.
On my developer machine it works to automate the app. However, when I use the app on another computer, it doesn't work anymore.

Are there any best practices regarding QT that I should take care of, in order to make it always-work ?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: About identifying QT dialogs

Post by odklizec » Thu Sep 27, 2018 1:52 pm

Hi,

Could you please post exact error message you are getting? Also, please post a Ranorex snapshot (NOT screenshot!) of the problematic element, ideally, taken on both machines, so we can see the difference. And don't forget to post the xpath, which works on one system, but fails on another. Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theselby
Posts: 8
Joined: Wed Sep 26, 2018 12:28 pm

Re: About identifying QT dialogs

Post by theselby » Thu Sep 27, 2018 3:17 pm

Hello,

Here's the repository that is working on my machine:

Code: Select all

<repository
id="85a0f281-3bea-4c58-8576-b1bff4024695"
name="JasminCam"
rxversion="8.1">
	<codegen
	classname="JasminCamV4"
	namespace="MyTestProject">
	</codegen>
	<rootfolder
	capname="host"
	id="cf155ac2-ac04-495b-894c-1bb9fecd9123"
	isrooted="True"
	name="Root"
	searchtimeout="3000ms"
	usecache="False">
		<appfolder
		addcaps="form,qtelement,qtwindow,nativewindow"
		capname="form"
		id="05eb089e-e8b5-4fef-a8be-2359a7d7198c"
		isrooted="True"
		name="Login"
		refpath="/form[@title='JasminCam']"
		searchtimeout="3000ms"
		usecache="True">
			<item
			addcaps="text,qtelement"
			capname="text"
			id="6d22f41f-0ddd-4f46-b4a4-f19dac359c62"
			name="MPasswordTxt"
			refimgid="e46b70cf-6598-48b7-b5d0-709815f27c06"
			refpath="/form[@title='JasminCam']/text[@name='mPasswordTxt']"
			searchtimeout="3000ms">
        /form[@title='JasminCam']/text[@name='mPasswordTxt']
      </item>
			<basepath>
        /form[@title='JasminCam']
      </basepath>
			<icon>
				iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAGbSURBVDhPpZE7TwJREIVnsaFAC21MxEZjoZ0J
xgd/wMqGRhNIiLFR44NEfwCJJrTU2lOJ7xeuqKhrcBGJoBijQRPNtlhJd5zZsEhBoVJ8Z2bOzJ3k
3ktZItQDZVjqgdIsv+G2hidQikXQa0Qrr1VbHl2zVHM/OIT3YBApR5NZJ5mcqw8foRCMcBhPIyNI
KorpS5+uWCw05nlxAaXSF/T2drN+mZnDaySChMuF0+4ePCwv4dHnq5yhC1LwAyEfCKBY/MQVL9A7
OvG2swvVZjN758wJE2ekFijBIpyVY3Z2FoZh4NLpxJ3fj5TXW+lJrM4lkmyztkpMT0+hUCgg0eaE
7vXhhhdIrxYyTyqLRdxuhz4/j3w+j3hrK1S+Ro7vrzY0VGaOquYFOmSJMdrwMB7TN8jdZpBci+KA
X/pAeqNjyK6uQHO7cdHbiwz/kObxQM4JtMcibDoasTc+jv2JCURbmtlTTH+bWevqQmxyEsf8wOv9
A9hkb78M7ZSHJG4x0pR8txytXPyNKs+C5NBfkWVWTuss9UBRvuv/UfAN4oDtyrDwuZMAAAAASUVO
RK5CYII=
			</icon>
		</appfolder>
		<basepath>
		</basepath>
	</rootfolder>
	<variables>
	</variables>
</repository>
Its pretty similar on the other machine, only the IDs are different
Also I manually changed the paths to be a little more specific, as in the following:
"/form[@title='JasminCam' and @processname='JCam-main' and @appname='JasminCam']/text[@name='mPasswordTxt']"

In code I do something like this:

Code: Select all

Stopwatch sw = new Stopwatch();
                
                Boolean found = false;
                sw.Start();

                while (!found)
                {
                    // here i try validating the existance of the app
                    found = Ranorex.Validate.Exists(@"/form[@title='JasminCam' and @processname='JCam-main' and @appname='JasminCam']", 
                        "Check for dialog existance... 'JasminCam'", false);

                    if (sw.Elapsed.TotalSeconds > 10)
                        break;
                }


                Boolean did = false;

                if (!did)
                {
                    MyTestProject.JasminCamV4 jsm = MyTestProject.JasminCamV4.Instance;
                    e.Result = false;
                    jsm.Login.SelfInfo.WaitForExists(new Ranorex.Duration(30 * 1000));

                    try
                    {
                        if (jsm.Login != null && jsm.Login.MPasswordTxt != null)
                        {
                            jsm.Login.MPasswordTxt.EnsureVisible();
                            jsm.Login.MPasswordTxt.TextValue = site.Password;
                            e.Result = true;
                            did = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        e.Result = ex.Message;
                    }
                }

                // try the other file
                if (!did)
                {
                    MyTestProject.JasminCam_Win7 jsm = MyTestProject.JasminCam_Win7.Instance;
                    e.Result = false;
                    jsm.Login.SelfInfo.WaitForExists(new Ranorex.Duration(30 * 1000));

                    try
                    {
                        if (jsm.Login != null && jsm.Login.MPasswordTxt != null)
                        {
                            jsm.Login.MPasswordTxt.EnsureVisible();
                            jsm.Login.MPasswordTxt.TextValue = site.Password;
                            e.Result = true;
                            did = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        e.Result = ex.Message;
                    }
                }

There are no errors reported. However, it behaves like its not finding the QT app/dialog and/or element.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: About identifying QT dialogs

Post by odklizec » Thu Sep 27, 2018 3:47 pm

Hi,

Please post the snapshot from both machines. If the ids are different on both machines, then you need to make the xpaths resistent to these changes. Unfortunately, without seeing, at very least, Ranorex snapshot (from both systems), there is no way anyone here can suggest better xpaths. Thanks.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theselby
Posts: 8
Joined: Wed Sep 26, 2018 12:28 pm

Re: About identifying QT dialogs

Post by theselby » Thu Sep 27, 2018 4:10 pm

Attached files to this reply.

Later Edit:
I added some debug logs on the runtime machine:

No element found for path '/form[@name='Login' and @processname='JCam-main']' within 10s.

No element found for path '/form[@name='Login' and @processname='JCam-main']/text[@name='mPasswordTxt']' within 5s.

No element found for path '/form[@title='JasminCam' and @processname='JCam-main' and @appname='JasminCam']/text[@name='mPasswordTxt']' within 5s.
You do not have the required permissions to view the files attached to this post.

theselby
Posts: 8
Joined: Wed Sep 26, 2018 12:28 pm

Re: About identifying QT dialogs

Post by theselby » Thu Sep 27, 2018 4:37 pm

On my machine, here is how it looks in spy:
my-machine-win10.JPG
While on the target machine, here's how it looks:
target-machine-win7.JPG
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: About identifying QT dialogs

Post by odklizec » Fri Sep 28, 2018 7:35 am

Hi,

The first problem I see is, that you are using different versions of Ranorex on both machines! You must use the same Ranorex version everywhere, otherwise, the results could be different:
RanorexVersion.png
As you can see, newer version of Ranorex (installed on Win7 machine) shows significantly more details about QT elements. There is a note in 8.2.1 release notes, that there is added support for QT tooltips. But it may be that they generally improved QT support?

Additionally, because you are using different versions of Windows, you will most probably have to optimize the xpaths on both systems. There is no way around. You see, things could look and behave differently on various systems. So if using the same Ranorex version on all systems does not fix your problem, you will have to find common xpaths, which will work on all systems.

BTW, make sure there is installed the same version of tested app on all systems and that there are installed the same versions of QT libs, .net and VC++ redistributable libs. Using the same versions of everything is essential for successful automation!
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

theselby
Posts: 8
Joined: Wed Sep 26, 2018 12:28 pm

Re: About identifying QT dialogs

Post by theselby » Fri Sep 28, 2018 11:08 am

Hey there,

Thanks for all the assistance.
Meanwhile I also discovered myself that I did something wrong when deploying the app:
1. i didn't had all vc++ redistributables installed
2. as of the runtimes... i only copied the DLL files, but forgot to also copy the subfolders

Doing the 2 points above, made it work. Many thanks

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: About identifying QT dialogs

Post by odklizec » Fri Sep 28, 2018 11:09 am

Hi,

You are welcome. Nice to hear you solved the problem ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration