Page 1 of 1

PopupWatcher not running when executed from Command line

Posted: Thu Mar 06, 2014 8:22 pm
by borisveis
I have a watcher usercode module which watches for a warning from the browser regarding self signed certificates. If a cert warning appears, the watcher will click through the various buttons to accept the self-signed cert and move on. I've placed this code module in [SETUP] section of the test suite.The suite contains two test cases Everything works fine when running from Ranorex Studio. However, I need it to run in our CI system which has a runtime license.

This appears to be a bug, but I'm not sure. Maybe I need to run something else in the command line to trigger SETUP. Screenshots and code below
Screen Shot 2014-03-06 at 11.11.59 AM.png
command line is executed from a CMD script. Note that there's a conditional which triggers the second test case. I have explicit mention of SETUP:

Code: Select all

@echo on
set tb=%1
set vm=%2
set configwiz=%3
set extip=%4
C:\source\ranorex\HTA-deployer\HTA-deployer\HTA-Console\bin\Debug\HTA-deployer.exe /ts:HTA-Console /tc:Console_Data /pa:DatacenterName=MKPHYS /pa:ClusterName="Cisco UCS" /pa:ResourcePoolName=Auto-Testing /pa:ResoucePoolTestBedName=%tb% /pa:hta_vmname=%vm%
IF %configwiz% == true (
	echo "----config wizard---"
	C:\source\ranorex\HTA-deployer\HTA-deployer\HTA-Console\bin\Debug\HTA-deployer.exe /ts:HTA-Console /tc:Config_Wizard /pa:htcc-ip=%extip%
)

Code: Select all

        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;
            
             // Create PopupWatcher  
			 PopupWatcher sslPopupWatcher = new PopupWatcher();
			 sslPopupWatcher.Watch(sslRepo.UntrustedConnection.FFIUnderstandTheRisksInfo, AcceptCertFF);
			 sslPopupWatcher.Watch(sslRepo.UntrustedConnection.IEOverridelinkInfo, AcceptCertIE); 
			 sslPopupWatcher.UpdateInterval = 8000;
		 
			 // Start PopupWatcher  
			 sslPopupWatcher.Start();
        }
        
        public static void AcceptCertFF(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)
		{
			Report.Log(ReportLevel.Info, "This appears to be Firefox");
	    	sslRepo.UntrustedConnection.FFIUnderstandTheRisks.Click();
	    	//Inserting delays for ease of debugging. You need a few seconds in case something goes wrong and you need to stop run
			Delay.Duration(3000, false);
        	sslRepo.UntrustedConnection.FFExceptionDialogButton.Click();
        	Delay.Duration(3000, false);
        	Keyboard.Press("{Tab}{Tab}{Tab}{Tab}");
        	Keyboard.Press("{Return}");	
		}
        
        public static void AcceptCertIE(Ranorex.Core.Repository.RepoItemInfo myInfo, Ranorex.Core.Element myElement)
		{
			Report.Log(ReportLevel.Info, "This appears to be IE");
			sslRepo.UntrustedConnection.IEOverridelink.Click();
		}     

Re: PopupWatcher not running when executed from Command line

Posted: Mon Mar 10, 2014 3:09 pm
by Support Team
Hello borisveis,

I have created a small sample solution, but I was not able to reproduce your issue. It is not necessary to add a special call of the setup/teardown area in order to execute them.

Which Ranorex version do you use?

Regards,
Robert

Re: PopupWatcher not running when executed from Command line

Posted: Mon Mar 10, 2014 9:56 pm
by borisveis
I'm using Ranorex Studio 4.1.5.17134. I installed the same package (without the Studio) in the runtime machine.

To repro, can you try to have two or more test cases with a setup function (see my screenshot in original post). Then, try to run the test cases separately and see if the watcher gets triggered.

I'm going to look closely at the text of the ssl warning and make sure they match with my sting search. It's possible that the versions of the browser on the runtime machine is different from the Studio machine.

Thanks,
Boris

Re: PopupWatcher not running when executed from Command line

Posted: Wed Mar 12, 2014 3:56 pm
by Support Team
Hello borisveis,

OK, I got it. The problem is that if you call a specific test case via command line using the command “/tc:” the parent test case which holds the [Setup]-area is not executed. I suggest either to call the parent test case or to add the [Setup]-area to the test case which is called.

Note:
If you call the parent test case please select the child test cases which should be executed by ticking off the check box previously. Build the project and run the executable via the command line interface.

Regards,
Robert

Re: PopupWatcher not running when executed from Command line

Posted: Thu Mar 13, 2014 12:30 am
by borisveis
Robert,
The SETUP is not in the test case section. It's in the Test Suite and I would expect it to mimic the behavior of Ranorex Studio. That said, based on my use case, I really didn't need the SETUP to be global to all test cases, only one specifically. Your suggestion to move it to the SETUP section of the test case solved the problem.

In the future though, we will use this SETUP more generally so I'd like to know if this is a Ranorex issue or is the behavior expected.

Thanks,
Boris

Re: PopupWatcher not running when executed from Command line

Posted: Fri Mar 14, 2014 9:17 am
by Support Team
Hello borisveis,

That’s the expected behavior since you more or less bypass the test suite by using the “/tc”- command.

I would suggest creating different test run configurations in order to use a “global” setup/tear-down area efficiently. So, you don’t need to specify which test cases should be executed within your batch-file anymore.

Regards,
Robert