lundi 26 mars 2018

How to call a running Ranorex test in a loop?

I have recorded & partly written a test for a Website, which works for a specific browser type. The user can modify a class field of the so-called EBrowserType type, which is an enum I have created. It contains all browser types that Ranorex can handle.

Now, I was asked to make a loop over the whole test, where all the browser types are called. I run into problems, as the existing test is a group of recordings, where the user clicked at some point into a text field of the opened browser of the requested browser type. This seems to be no more possible in a loop, as the code itself creates the browser & closes it after that.

In the original code, there is a SETUP part that openes the browser, and a recording that follows. enter image description here This recording is called SearchJobRegionRecording & starts with a mouse click into the search field of the browser. In the automatically created C# file, this looks as follows:

   [TestModule("c7957eb6-feec-4dce-aef3-6af20fa71b8b", ModuleType.Recording, 1)]
public partial class SearchJobRegionRecording : ITestModule
{
    /// <summary>
    /// Holds an instance of the IVMJobsiteTest.IVMWebsiteTestRepository repository.
    /// </summary>
    public static IVMJobsiteTest.IVMWebsiteTestRepository repo = IVMJobsiteTest.IVMWebsiteTestRepository.Instance;
    […]

    [System.CodeDom.Compiler.GeneratedCode("Ranorex", "8.0")]
    void ITestModule.Run()
    {
        Mouse.DefaultMoveTime = 0;
        Keyboard.DefaultKeyPressTime = 0;
        Delay.SpeedFactor = 100.00;

        Init();

        Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'Home.Text' at 128;8.", repo.Home.TextInfo, new RecordItemIndex(0));
        repo.Home.Text.Click("128;8");
        […]
    }
}

As you can see, a repo object is required to access the browser instance. enter image description here enter image description here My question: How can I get the browser instance in my browser-looping code? The only hint about the created browser seems to be the process ID.

Here is the respective part for the browser-looping code:

    public void TestAllBrowsers()
{
    foreach (EBrowserType browser in Enum.GetValues(typeof(EBrowserType)))
    {
        foreach (Point size in sizes)
        {
            Report.Log(ReportLevel.Info, "Code", "Open with the " + browser + " browser of "
                       + size.X + '×' + size.Y + " size " + url);
            BaseCodeCollection.KillCurrentBrowser(browser);
            var height = (short) size.X;
            var width = (short) size.Y;

            int processID = BaseCodeCollection.OpenBrowser(height, width, url, browser, isVerbose);

            DetermineOriginalVacancies();

            EnterSearchWords(); // HERE, A RepoInfoItem or something like that should be passed so that a mouse click is possible.

            AnalyzeSearchResultsMethod();

            CloseBrowser();
        }

    }
}

Aucun commentaire:

Enregistrer un commentaire