I converted a action item in a recorded module to a UserCode action. In the UserCode.cs I added code, one line was a call to use an existing Recorded Module which contains variables. How do I bind to these variables in this Recorded Module to the data table I'm using with the parent Test Case/Test Suite?
I am calling module using Recordings.AddConsultantWebsiteSubscription.Start();
Here is the UserCode.ie:
///////////////////////////////////////////////////////////////////////////////
//
// This file was automatically generated by RANOREX.
// Your custom recording code should go in this file.
// The designer will only add methods to this file, so your custom code won't be overwritten.
// http://www.ranorex.com
//
///////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Repository;
using Ranorex.Core.Testing;
using TieredRegression.Recordings;
namespace TieredRegression.Recordings
{
public partial class ConfirmConsultantHasValidWebsiteSubscription
{
/// <summary>
/// This method gets called right after the recording has been started.
/// It can be used to execute recording specific initialization code.
/// </summary>
private void Init()
{
// Your recording specific initialization code goes here.
}
/// <summary>
/// Method validates the Manage button exists, if it is not, then check if Subscribe button exists.
/// If Subscribe boon existes then call module to add subscription and allow TC continue.
/// If Manage nor Subscribe buttons do not exist then fail validation test.
/// </summary>
/// <param name="webelementInfo"></param>
public void Validate_WebsiteSubscriptionManageLink(RepoItemInfo webelementInfo)
{
if (webelementInfo.Exists())
{
Report.Log(ReportLevel.Info, "Validation", "Validating Exists on item 'Testing.WebsiteSubscriptionManageLink'.", repo.ThirtyOneGifts.WebsiteSubscriptionManageLinkInfo, new RecordItemIndex(0));
Validate.Exists(repo.ThirtyOneGifts.WebsiteSubscriptionManageLinkInfo);
Delay.Milliseconds(0);
}
else
{
Report.Log(ReportLevel.Warn, "Validation", "Unable to Validate Exists on item 'Website Subscription Manage Link'. May not have active Website Subscription? ", webelementInfo);
var personalWebsiteSubscripeButton = repo.ThirtyOneGifts.PersonalWebsiteSubscribeButtonInfo;
if (personalWebsiteSubscripeButton.Exists())
{
Report.Log(ReportLevel.Success, "Validation", "Validating Exists on item 'Personal Website Subscribe Button'. ", personalWebsiteSubscripeButton);
Report.Warn("Validation", "Calling 'AddConsultantWebsiteSubscription.rxrec' to add an active subscription.");
Recordings.AddConsultantWebsiteSubscription.Start();
}
else
{
Report.Log(ReportLevel.Info, "Validation", "Validating Exists on item 'Testing.WebsiteSubscriptionManageLink'.", repo.ThirtyOneGifts.WebsiteSubscriptionManageLinkInfo, new RecordItemIndex(0));
Report.Failure("Validation","Failed Validating Exists on item 'Testing.WebsiteSubscriptionManageLink'.");
Ranorex.Validate.Fail("Failed to find item 'Testing.WebsiteSubscriptionManageLink'.");
}
}
}
}
}
Binding variables in UserCode
Re: Binding variables in UserCode
Hi,
And this is why it will always fail. You must insert the code module to the solution, otherwise, you will be unable to bind the variables. There is no way to bind a module variable to the data connector, if the module is not placed in solution. Starting modules using Start() method, is generally bad idea.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
Re: Binding variables in UserCode
Thank you for confirming this, so when I use a code module then I can access the variable to bind. I will create a new Code Module.
Re: Binding variables in UserCode
When you do get around to creating your code module, the variables are created a little different. Right click the code editor while your code module is open and select Insert new module variable.
If you just create a normal var in code like then Ranorex will not be able to bind data to this variable as is. The method above creates the variable for you including get/set and a GUID.
hope this helps
If you just create a normal var in code like
Code: Select all
int abc = 0;
hope this helps
You do not have the required permissions to view the files attached to this post.