CreateAdapter with click location editing

Ask general questions here.
willmtz
Posts: 13
Joined: Thu Jan 30, 2014 9:29 pm

CreateAdapter with click location editing

Post by willmtz » Fri Feb 14, 2014 9:55 pm

Hello,
This is my first use of "Code: Select All," I hope it will be displayed properly.

Problem Description:
I inherited an app test suite with computer, and unfortunately the Test Developer did not provide, or created any type of “set up instructions." Consequently there are many conditions which I believe need to be met in order for the test cases to run successfully. Conditions such as; Monitor resolution, screen text size setting, positioning of the browser, etc..
I perceive the problem being that the browser is not positioned in the original location, and hence any other window form will also be at the wrong location. It is interesting that a URL link within the initial browser window is found, validated and launched, and yet it cannot minimize the browser.

In using Rx SPY, I observed and used the “location” settings displayed by Spy, in hopes of debugging the first failure I am encountering. I am assuming that I would have to set new location settings throughout the test cases, if this is the problem. I have tried the SPY: location, Mouse Relative, and Mouse Screen, location settings for debugging, but these settings have not solved the code failure.
It could be that the “CreateAdapter” class is not finding what it needs to function properly.

Single stepping through the code, I get up to this line, as shown in the “code snippet”;
return _javaconsoletigeruiautotestutInfo.CreateAdapter<Ranorex.TitleBar>(true)
On the next single step, the code automatically runs (I’m not allowed to single step, the button is grayed out.).

It is very evident where the failures start, as shown in the listed Java console output;

[Info ][Test]: Test Module 'MinimizeJavaConsole' started.
[Info ][Mouse]: click console header for focus
Mouse Left Click item 'JavaConsoleTIGERUIAutoTestUT.JavaConsoleTIGERUIAutoTestUT' at 1155;16.
[Error ][Module]: Failed to find item 'TigerSmokeSuiteRepository.JavaConsoleTIGERUIAutoTestUT.JavaConsoleTIGERUIAutoTestUT'.<br/>No
element found for path '/form[@title~'^Java\ Console\ -\ TIGER\ -\ UI']/titlebar[@accessiblerole='TitleBar']' within 1m.
[Failure][Test]: Test Module 'MinimizeJavaConsole' completed with status 'Failed'.
[Failure][Test]: Test Case 'SmokeSuitePSY' completed with status 'Failed'.


System Detailed description:
OS Name Microsoft Windows 7 Enterprise
Version 6.1.7601 Service Pack 1 Build 7601
System Model Precision WorkStation T3500
System Type x64-based PC
Processor Intel(R) Xeon(R) CPU W3530 @ 2.80GHz, 2800 Mhz, 4 Core(s), 4 Logical Processor(s)
BIOS Version/Date Dell Inc. A07, 4/12/2010
SMBIOS Version 2.5
Hardware Abstraction Layer Version = "6.1.7601.17514"

IE 8 Version: 8.0.7601.17514
Ranorex Developer Premium, Studio 4.1.1.15872 .NET Runtime Version 4.0.30319.18408

CODE: SELECT ALL
//
/// <summary>
        /// The JavaConsoleTIGERUIAutoTestUTAppFolder folder.
        /// </summary>
        [RepositoryFolder("13139a93-11a5-4852-89db-312fb0d86054")]
        public partial class JavaConsoleTIGERUIAutoTestUTAppFolder : RepoGenBaseFolder
        {
            RepoItemInfo _javaconsoletigeruiautotestutInfo;
            RepoItemInfo _minimizeInfo;

            /// <summary>
            /// Creates a new JavaConsoleTIGERUIAutoTestUT  folder.
            /// </summary>
            public JavaConsoleTIGERUIAutoTestUTAppFolder(RepoGenBaseFolder parentFolder) :
                    base("JavaConsoleTIGERUIAutoTestUT", "/form[@title~'^Java\\ Console\\ -\\ TIGER\\ -\\ UI']", parentFolder, 30000, null, false, "13139a93-11a5-4852-89db-312fb0d86054", "")
            {
                _javaconsoletigeruiautotestutInfo = new RepoItemInfo(this, "JavaConsoleTIGERUIAutoTestUT", "titlebar[@accessiblerole='TitleBar']", 30000, null, "e6e86e2b-2376-402c-ac09-0336ca37468f");
                _minimizeInfo = new RepoItemInfo(this, "Minimize", "titlebar/button[@accessiblename='Minimize']", 30000, null, "a4d817f9-a914-48f7-aea3-a91a75bc2805");
            }
            
/// <summary>
            /// The Self item.
            /// </summary>
            [RepositoryItem("13139a93-11a5-4852-89db-312fb0d86054")]
            public virtual Ranorex.Form Self
            {
                get
                {
                    return _selfInfo.CreateAdapter<Ranorex.Form>(true);
                }
            }

            /// <summary>
            /// The Self item info.
            /// </summary>
            [RepositoryItemInfo("13139a93-11a5-4852-89db-312fb0d86054")]
            public virtual RepoItemInfo SelfInfo
            {
                get
                {
                    return _selfInfo;
                }
            }

            /// <summary>
            /// The JavaConsoleTIGERUIAutoTestUT item.
            /// </summary>
            [RepositoryItem("e6e86e2b-2376-402c-ac09-0336ca37468f")]
            public virtual Ranorex.TitleBar JavaConsoleTIGERUIAutoTestUT
            {
                get
                {
                    return _javaconsoletigeruiautotestutInfo.CreateAdapter<Ranorex.TitleBar>(true);
                }
            }


CODE: SELECT ALL
//
        /// <summary>
        /// Starts the replay of the static recording <see cref="Instance"/>.
        /// </summary>
        [System.CodeDom.Compiler.GeneratedCode("Ranorex", "4.1.1")]
        public static void Start()
        {
            TestModuleRunner.Run(Instance);
        }

        /// <summary>
        /// Performs the playback of actions in this recording.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        [System.CodeDom.Compiler.GeneratedCode("Ranorex", "4.1.1")]
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;

            Init();

            // click console header for focus
            Report.Log(ReportLevel.Info, "Mouse", "click console header for focus\r\nMouse Left Click item 'JavaConsoleTIGERUIAutoTestUT.JavaConsoleTIGERUIAutoTestUT' at 1155;16.", repo.JavaConsoleTIGERUIAutoTestUT.JavaConsoleTIGERUIAutoTestUTInfo, new RecordItemIndex(0));
            repo.JavaConsoleTIGERUIAutoTestUT.JavaConsoleTIGERUIAutoTestUT.Click("1155;16", 280);
            // was this:
//repo.JavaConsoleTIGERUIAutoTestUT.JavaConsoleTIGERUIAutoTestUT.Click("279;11", 280);
            Delay.Milliseconds(0);
One puzzling aspect about this code is that the JavaConsole usage is not showing up within the recordings I have done. For example this line; JavaConsoleTIGERUIAutoTestUTAppFolder(RepoGenBaseFolder parentFolder). Could anyone identify what it might be?
Last edited by willmtz on Thu Feb 20, 2014 9:37 pm, edited 1 time in total.

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: CreateAdapter with click location editing

Post by Swisside » Mon Feb 17, 2014 9:41 am

Hi,

After reading through your code snippets I think the previous developer wrote something very complicated to execute a very simple action.

I could propose something much simpler but I'm not sure it's what you are looking for.

The error is quite simple to resolve it only means that Ranorex cannot find the console it has to minimize. I would suggest to start Spy then open (manually) the console you have to minimize and then verify the path indicated in Spy is the same that the one in your code snippet
public JavaConsoleTIGERUIAutoTestUTAppFolder(RepoGenBaseFolder parentFolder) :  
                    base("JavaConsoleTIGERUIAutoTestUT", "/form[@title~'^Java\\ Console\\ -\\ TIGER\\ -\\ UI']", parentFolder, 30000, null, false, "13139a93-11a5-4852-89db-312fb0d86054", "")
It's possible the window title has changed for instance.

If it's still not clear how to solve the issue you can post a snapshot of the JavaConsole in Spy.


Regards

Swiss'
A simple thank you always does wonders !

willmtz
Posts: 13
Joined: Thu Jan 30, 2014 9:29 pm

Re: CreateAdapter with click location editing

Post by willmtz » Wed Feb 19, 2014 9:29 pm

Swiss, I gathered the information you requested and I “properly” edited the rxrec with the Spy browser titlebar with a location of 430;20. This location is from a trail script I recorded, using the new position for the browser. This location does not correspond with any of the locations I saw with Spy, as shown below.
I have saved several snapshots, and decided to include them all. The “From TIGER launch IE” snapshot is the one I am actually working with. The others are “trial scripts.”
Any comments you may have will be greatly appreciated.

Also, I am interested in learning why the RxLog Rxpath for the titlebar is different.

Spy: /form[@title~'^TIGER\ Launcher\ -\ Windows\ ']/titlebar[@accessiblerole='TitleBar']
Rxlog: /form[@title~'^Java\ Console\ -\ TIGER\ -\ UI']/titlebar[@accessiblerole='TitleBar']'
Trial script: /form[@title~'^TIGER\ Launcher\ -\ Windows\ ']/titlebar[@accessiblerole='TitleBar']

Location: 253;59 mouse relative; 194;19 mouse screen; 447;78
Image1.PNG
Minimize button
/form[@title~'^TIGER\ Launcher\ -\ Windows\ ']/?/?/button[@accessiblename='Minimize']

Location: 1308;57 mouse relative; 16;21 mouse screen; 1324;78
Image2.PNG
trial script: Header title and Minimize button
CODE: SELECT ALL
//
[System.CodeDom.Compiler.GeneratedCode("Ranorex", "4.1.1")]
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;

            Init();

            Report.Log(ReportLevel.Info, "Application", "Run application 'http://j-rmrqa2app-m:8080/tiger-UITest/' with arguments '' in normal mode.", new RecordItemIndex(0));
            Host.Local.RunApplication("http://app-m:8080/tiger-UITest/", "", "", false);
            Delay.Milliseconds(0);
            
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'TIGERLauncherWindowsInternetExplor.TIGERLauncherWindowsInternetExplor' at 430;20.", repo.TIGERLauncherWindowsInternetExplor.TIGERLauncherWindowsInternetExplorInfo, new RecordItemIndex(1));
            repo.TIGERLauncherWindowsInternetExplor.TIGERLauncherWindowsInternetExplor.Click("430;20");
            Delay.Milliseconds(200);
            
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'TIGERLauncherWindowsInternetExplor.Minimize' at 17;17.", repo.TIGERLauncherWindowsInternetExplor.MinimizeInfo, new RecordItemIndex(2));
            repo.TIGERLauncherWindowsInternetExplor.Minimize.Click("17;17");
            Delay.Milliseconds(200);
            
        }
Swiss, I later managed to step through the code up to this block of code, and the title bar is correct. I changed the button click from "middle" to "left," and used the 430;20 location.
CODE: SELECT ALL
//
       [System.CodeDom.Compiler.GeneratedCode("Ranorex", "4.1.1")]
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;

            Init();

            // click for focus
            Report.Log(ReportLevel.Info, "Mouse", "click for focus\r\nMouse Left Click item 'TIGERLauncherWindowsInternetExplor1.TIGERLauncherWindowsInternetExplor' at 430;20.", repo.TIGERLauncherWindowsInternetExplor1.TIGERLauncherWindowsInternetExplorInfo, new RecordItemIndex(0));
            repo.TIGERLauncherWindowsInternetExplor1.TIGERLauncherWindowsInternetExplor.Click("430;20");
            Delay.Milliseconds(4280);
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: CreateAdapter with click location editing

Post by Support Team » Fri Feb 21, 2014 5:31 pm

Hi Willmtz,

I am unfortunately not sure I got the issue, but when you just want to minimize the browser you can just use the Invoke Action->Minimize on the main form of the browser as shown below:
Minimize.png
Ranorex can identify the elements without the need to know where they are located on the screen. Ranorex will identify the elements based on their unique RxPath and regardless their position.
Maybe you can explain in some words what you are trying to do?

Thanks,
Markus
You do not have the required permissions to view the files attached to this post.

willmtz
Posts: 13
Joined: Thu Jan 30, 2014 9:29 pm

Re: CreateAdapter with click location editing

Post by willmtz » Fri Feb 21, 2014 11:09 pm

Markus, thank you for your help. Your comments helped me solve my problems.
thanks,
will