Help Using Data Source for Variable Gender selection

Ask general questions here.
Qbert
Posts: 2
Joined: Fri Dec 23, 2016 7:26 pm

Help Using Data Source for Variable Gender selection

Post by Qbert » Fri Dec 23, 2016 8:15 pm

Hi all,

New to Ranorex 6.2 and automation (on day 10 of trail), great tool but finally ran into a challenge I cannot get around even after looking thru the user guide, blogs and forum.

I am re-creating the Cross browser Testing Automation found on the Ranorex blog.

I have everything working except the selection of M/F as per the data source setup. Specifically from the blog mentioned above: 'The gender can be set by adding a variable to the RanoreXPath of the corresponding repository item.'

How do I do this?

My data source is setup and bound as per the blog...FirstName, LastName & Category all pull up the data iterations as expected, but when the automation gets to the gender selection it just hangs and fails. I have tried to use the 'Make Repository Item Variable' function but get lost when I start to look at all the options under the General thru Dynamic sections on the right (I am not well versed in coding or Spy yet).

The 'gender' path in my recording looks exactly as the one on the blog: .//td[#'gender']//td[@innertext>$gender]/input

--> I just need help on what I missed or steps on what I need to do to get the automation to work with the gender variables I have in my data source. Thanks in advance!...

Here is the Ranorex generated code as well:
///////////////////////////////////////////////////////////////////////////////
//
// This file was automatically generated by RANOREX.
// DO NOT MODIFY THIS FILE! It is regenerated by the designer.
// All your modifications will be lost!
//
//
///////////////////////////////////////////////////////////////////////////////

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.Testing;
using Ranorex.Core.Repository;

namespace CrossBrowserTrain1
{
#pragma warning disable 0436 //(CS0436) The type 'type' in 'assembly' conflicts with the imported type 'type2' in 'assembly'. Using the type defined in 'assembly'.
/// <summary>
///The AddVIPs recording.
/// </summary>
[TestModule("9a154ca6-a1be-4a49-b7ab-d59acb91c81c", ModuleType.Recording, 1)]
public partial class AddVIPs : ITestModule
{
/// <summary>
/// Holds an instance of the CrossBrowserTrain1Repository repository.
/// </summary>
public static CrossBrowserTrain1Repository repo = CrossBrowserTrain1Repository.Instance;

static AddVIPs instance = new AddVIPs();

/// <summary>
/// Constructs a new instance.
/// </summary>
public AddVIPs()
{
FirstName = "$FirstName";
LastName = "$LastName";
Category = "$Category";
Gender = "$Gender";
}

/// <summary>
/// Gets a static instance of this recording.
/// </summary>
public static AddVIPs Instance
{
get { return instance; }
}

#region Variables

/// <summary>
/// Gets or sets the value of variable Gender.
/// </summary>
[TestVariable("ed0fc3c1-84d1-44f2-bc6f-0cd75b65e16c")]
public string Gender
{
get { return repo.gender; }
set { repo.gender = value; }
}

/// <summary>
/// Gets or sets the value of variable FirstName.
/// </summary>
[TestVariable("52ea5ce9-9436-4757-9524-7a20554042f2")]
public string FirstName
{
get { return repo.FirstName; }
set { repo.FirstName = value; }
}

/// <summary>
/// Gets or sets the value of variable LastName.
/// </summary>
[TestVariable("b2eb35c3-75a5-4811-869a-5324b74556b8")]
public string LastName
{
get { return repo.LastName; }
set { repo.LastName = value; }
}

/// <summary>
/// Gets or sets the value of variable Category.
/// </summary>
[TestVariable("cdd64244-4efa-466f-8a4f-0dec8a482231")]
public string Category
{
get { return repo.Category; }
set { repo.Category = value; }
}

#endregion

/// <summary>
/// Starts the replay of the static recording <see cref="Instance"/>.
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("Ranorex", "6.2")]
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", "6.2")]
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.00;

Init();

Report.Log(ReportLevel.Info, "Keyboard", "Key sequence from variable '$FirstName' with focus on 'RanorexVIPDatabaseTestWebApplicatio.VIP_Data.FirstName'.", repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.FirstNameInfo, new RecordItemIndex(0));
repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.FirstName.PressKeys(FirstName);
Delay.Milliseconds(0);

Report.Log(ReportLevel.Info, "Keyboard", "Key sequence from variable '$LastName' with focus on 'RanorexVIPDatabaseTestWebApplicatio.VIP_Data.LastName'.", repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.LastNameInfo, new RecordItemIndex(1));
repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.LastName.PressKeys(LastName);
Delay.Milliseconds(0);

Report.Log(ReportLevel.Info, "Set Value", "Setting attribute TagValue to '$Category' on item 'RanorexVIPDatabaseTestWebApplicatio.VIP_Data.Category'.", repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.CategoryInfo, new RecordItemIndex(2));
repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.Category.Element.SetAttributeValue("TagValue", Category);
Delay.Milliseconds(0);

Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'RanorexVIPDatabaseTestWebApplicatio.VIP_Data.Gender' at Center.", repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.GenderInfo, new RecordItemIndex(3));
repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.Gender.Click();
Delay.Milliseconds(200);

Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'RanorexVIPDatabaseTestWebApplicatio.VIP_Data.InputTagAdd' at 17;12.", repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.InputTagAddInfo, new RecordItemIndex(4));
repo.RanorexVIPDatabaseTestWebApplicatio.VIP_Data.InputTagAdd.Click("17;12");
Delay.Milliseconds(200);

}

#region Image Feature Data
#endregion
}
#pragma warning restore 0436
}

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Help Using Data Source for Variable Gender selection

Post by Support Team » Tue Dec 27, 2016 2:55 pm

Hi Qbert,

I just checked our blog posting, re-created the project and found some discrepancies. It seems that IE generates a different innertext for the inputvalues than other browsers. Therefore, I've created a small sample solution which shows those steps just in the Chrome browser.

If you need further help, I'd recommend getting in touch with us by email, so we can discuss the problem in more detail.

Regards,
Markus (S)
Attachments
CrossBrowserTest.zip
Sample Solution
(43.34 KiB) Downloaded 23 times
.
Image

Qbert
Posts: 2
Joined: Fri Dec 23, 2016 7:26 pm

Re: Help Using Data Source for Variable Gender selection

Post by Qbert » Wed Dec 28, 2016 1:48 am

Support Team wrote:Hi Qbert,

I just checked our blog posting, re-created the project and found some discrepancies. It seems that IE generates a different innertext for the inputvalues than other browsers. Therefore, I've created a small sample solution which shows those steps just in the Chrome browser.

If you need further help, I'd recommend getting in touch with us by email, so we can discuss the problem in more detail.

Regards,
Markus (S)
Hi Markus,

Thank you very much! This works and I have it working in all 3 browsers now. Victory! I'm sure I'll have more questions in the future so I hope you don't get tired of my noobness. :D

Happy Holidays,
John