Testing a Web client & Win client in the one script!

Ask general questions here.
benny28
Posts: 34
Joined: Thu May 31, 2012 4:48 pm
Location: London
Contact:

Testing a Web client & Win client in the one script!

Post by benny28 » Thu May 31, 2012 4:56 pm

Hello,

I have a requirement to test interactions between 2 systems; one is a Web Client and one is a Windows Client.

So far I have been automation the Web Client using Selenium and the Win Client Using Ranorex.

Now I need to test the 2 clients in one script, should I:
a). use Ranorex for both Web and Win clients (the problem I see here is that when you start to record a script only one option to specify the Application or URL is given)
b). create test script using a combination of selenium and ranorex (note that I am not sure if this is even possible yet)
c). something different?

I like option B if it is possible, as I confident with Selenium web test methods. But I do not know how to define 2 different testing frameworks; ie. Selenium & Ranorex in one script!

Any thoughts folks?
I cannot be the first person that wants to automate interactions between 2 or more app's in the one test! :?

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Testing a Web client & Win client in the one script!

Post by Ciege » Thu May 31, 2012 6:57 pm

Sure, you can do both from within one script with Ranorex I do it all the time. I strongly recommend you learn how to write your own code to do it and move away from record and playback.

For B, you can use Ranorex to kick off your existing selenium scripts. As long as you go through all your Windows client stuff first, then through all your web client stuff next, I don't see a problem with that. However, if you must do one thing in the Win client, then something in the web client, then back to the Win client etc... Then you will need to write extra code in both scripts to communicate with each other as to what the current state is and what the next step is.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

benny28
Posts: 34
Joined: Thu May 31, 2012 4:48 pm
Location: London
Contact:

Re: Testing a Web client & Win client in the one script!

Post by benny28 » Fri Jun 01, 2012 11:58 am

Okay this is good news. Yeah I would never use Selenium record and playback to build scripts and I hope to move away from Ranorex's too, I'm a firm believer in writing the code directly. But at this early stage I still have to relay on it.

I will need to start the Web Client firstly and then the Windows Client after wards. In this application the web client is Admin (so to speak) and the Windows clients is for the users.

So I can start the scripts using Ranorex and then insert my Selenium actions where necessary! This would be great if I get it working.

Do you know of any examples / tutorials online dealing with this or similar?

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Testing a Web client & Win client in the one script!

Post by Ciege » Fri Jun 01, 2012 3:47 pm

benny28 wrote:Do you know of any examples / tutorials online dealing with this or similar?
Sorry, I don't use Selenium so I can't comment specifically... But, with Ranorex, you can do whatever you can do normally with C#/VB.NET. So all you need to do is figure out how to call a selenium module. Is selenium compiled into an EXE that you can call? If so, that will be quite easy to just call the EXE whenever you need to run it.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
sdaly
Posts: 238
Joined: Mon May 10, 2010 11:04 am
Location: Dundee, Scotland

Re: Testing a Web client & Win client in the one script!

Post by sdaly » Fri Jun 01, 2012 3:59 pm

Here is one of my blog posts on using Selenium Webdriver with C# and NUnit - http://soft-test-tech.co.uk/2011/09/sel ... h-c-nunit/.

If you implement that example then add a reference to Ranorex, then add "Using Ranorex;", you can use both Ranorex and Selenium from the same project, fixture, test, whatever! Not sure why you would want to use both Selenium and Ranorex though, why not just use Ranorex for both web and app testing?

benny28
Posts: 34
Joined: Thu May 31, 2012 4:48 pm
Location: London
Contact:

Re: Testing a Web client & Win client in the one script!

Post by benny28 » Thu Jun 07, 2012 5:11 pm

sdaly wrote:...add a reference to Ranorex, then add "Using Ranorex;", you can use both Ranorex and Selenium from the same project, fixture, test, whatever!
Excellent, works like a charm :D I'm confident with Selenium but not with Ranorex, and initially I was trying to add my Selenium steps into a recorded/outputted code of Ranorex... and basically it was messing with my head!!
sdaly wrote:Not sure why you would want to use both Selenium and Ranorex though, why not just use Ranorex for both web and app testing?
Yeah I knew someone would ask me this :D I want to continue to use Selenium because the Web Client project already has many Selenium scripts and I want to utilise all previous work done.



Here is my code for future reference:

Code: Select all

using System;
using System.Threading;
using Selenium;
using NUnit.Framework;

using Ranorex;
using findEuro;

namespace GtsAutomation.TestScripts.Template
{

    [TestFixture]
    public class SeleniumRanorex
    {
        private ISelenium selenium;
        private string now;

        [SetUp]
        public void SetupTest()
        {
            now = System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
            selenium = new DefaultSelenium(Config.Host, 4444, Config.Browser, Config.Url);
            selenium.Start();
            selenium.SetSpeed(Config.SetSpeed);
            selenium.WindowMaximize();
        }

        [TearDown]
        public void TeardownTest()
        {
            selenium.Stop();
        }


        // Ranorex 
        public static findEuroRepository repo = findEuroRepository.Instance;

        [Test]
        public void StockAdjustmentActionLog0215()
        {
            // Open site URL
            selenium.Open(Config.Url);

            // select Stock and Adjustment
            selenium.ClickAndWait(Menu.Stock);
            // etc

            // instigate Ranorex
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;

            //Init();

            Report.Log(ReportLevel.Info, "Application", "Run application 'C:\\Application For Test\\Application.exe' with arguments '' in normal mode.", new RecordItemIndex(0));
            Host.Local.RunApplication("C:\\Application For Test\\Application.exe", "", "", false);
            Delay.Milliseconds(0);

            Validate.Exists(repo.FormLogOn___Global_Trading_S.TextLoginInfo);
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'FormLogOn___Global_Trading_S.TextLogin' at 6;10.", repo.FormLogOn___Global_Trading_S.TextLoginInfo, new RecordItemIndex(1));
            repo.FormLogOn___Global_Trading_S.TextLogin.Click("6;10");
            Delay.Milliseconds(0);

            Validate.Exists(repo.FormHome___Global_Trading_Sy.ElementConnectionStatusPopupInfo);
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'FormHome___Global_Trading_Sy.ElementConnectionStatusPopup' at 1893;13.", repo.FormHome___Global_Trading_Sy.ElementConnectionStatusPopupInfo, new RecordItemIndex(17));
            repo.FormHome___Global_Trading_Sy.ElementConnectionStatusPopup.Click("1893;13");
            Delay.Milliseconds(0);

            Validate.Exists(repo.FormGlobal_Trading_System.ButtonYesInfo);
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'FormGlobal_Trading_System.ButtonYes' at 26;10.", repo.FormGlobal_Trading_System.ButtonYesInfo, new RecordItemIndex(18));
            repo.FormGlobal_Trading_System.ButtonYes.Click("26;10");
            Delay.Milliseconds(0);
            
        }
    }
}
Thank you all... :mrgreen: