Validate - NotExists with right click disabled
-
- Posts: 56
- Joined: Wed Jun 10, 2015 4:35 pm
Validate - NotExists with right click disabled
Hi. This may be a unique attempt. I have a dropdown which has one value alone (gr1). My Test is to ensure that the drop down do not have anything other than gr1. Hence, need to validate to see if gr2 does not exist. Problem is when i click on Select dropdown box gr1 is visible, if i then click on the recorder validate option, gr1 which was brought by clicking on select dropdown box get invisible. I then have to click again on dropdown box to bring gr1, but never select validate on gr1 (so that i can change to gr2 does not exist. PFA Snapshot.
You do not have the required permissions to view the files attached to this post.
-
- Certified Professional
- Posts: 74
- Joined: Mon Aug 14, 2006 7:17 pm
- Location: CH
Re: Validate - NotExists with right click disabled
Hi,
If I understood you correctly, then you have the following possibility.
That what you want to achieve you can do over user code.
First of all forget clicking on select tags, it will never work, if do cross browser testing.
If you want to Validate and set or unset the value, you can do this over user code.
Add on the User Code and create function like.
Dan
If I understood you correctly, then you have the following possibility.
That what you want to achieve you can do over user code.
First of all forget clicking on select tags, it will never work, if do cross browser testing.
If you want to Validate and set or unset the value, you can do this over user code.
Add on the User Code and create function like.
using System.Core; public void SetSelectTagByOptionValue(RepoItemInfo repoInfo, string optionValue) { var element = repoInfo.CreateAdapter<Unkown>(true); SelectTag ranorexSelectTag = element.Element; IList<OptionTag> options = ranorexSelectTag.Options; IList<OptionTag> optionTagList = options.Where(tempOption => tempOption.Value!= null && tempOption.Value.Trim().Equals(optionValue.Trim(),StringComparison.OrdinalIgnoreCase)).ToList(); if(optionTagList.Count == 1) { OptionTag singleOptionTag = optionTagList.ElementAt(0); singleOptionTag.Selected = true; ranorexSelectTag.TagValue = singleOptionTag.Value; } }And if you want to validate the selecttag when the value is set you have to replace the code in the if section. With
Element selectedElement = selectedOptionTagEnum.ElementAt(0).Element; Validate.Attribute(selectedElement ,attributeValue, expectedValue, "The expected value {3} from item " + repoInfo.Name + " of type: " + selectedElement.PreferredCapability.DisplayName + " on attribute {1} could be validated");Cheers
Dan
-
- Posts: 56
- Joined: Wed Jun 10, 2015 4:35 pm
Re: Validate - NotExists with right click disabled
Hi Dan,
I have created a new .cs file (SelectTextbox) and have the following code in it.
/*
* Created by Ranorex
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
using System.Core;
namespace Test1
{
/// <summary>
/// Use this module at any position of your test suite to get informed about test runs by email.
/// This is especially useful for overnight test executions on runtime machines.
/// </summary>
[TestModule("EEE7C8D8-D950-40EF-B24A-1A9A87C0DA21", ModuleType.UserCode, 1)]
public class SendMailModule : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public SendMailModule()
{
// Do not delete SendMailModule method - a parameterless constructor is required!
}
#region Variables
string _to = "[email protected]";
[TestVariable("D089186D-7919-4023-8165-B68F9151C6A7")]
public string To
{
get { return _to; }
set { _to = value; }
}
string _from = "[email protected]";
[TestVariable("BDB3FC8C-1E51-448F-9049-AEF0B247DBDB")]
public string From
{
get { return _from; }
set { _from = value; }
}
string _subject = "Ranorex eMail Module Report";
[TestVariable("398FF772-C15C-4b91-954B-34CC636DEDC9")]
public string Subject
{
get { return _subject; }
set { _subject = value; }
}
string _serverHostName = "Smtp.gea.com";
[TestVariable("0EE4CB1E-D738-4DE8-B122-92B3CCE6F70C")]
public string ServerHostname
{
get { return _serverHostName; }
set { _serverHostName = value; }
}
string _serverPort = "25";
[TestVariable("4C6A889D-BACE-4AE1-9EEF-40EA26775574")]
public string ServerPort
{
get { return _serverPort; }
set { _serverPort = value; }
}
string _message = "Ranorex Success email configuration";
[TestVariable("D49672F4-3021-4460-96DA-2EC11AE318A8")]
public string Message
{
get { return _message; }
set { _message = value; }
}
#endregion
void ITestModule.Run()
{
}
public void SetSelectTagByOptionValue(RepoItemInfo repoInfo, string optionValue)
{
var element = repoInfo.CreateAdapter<Unkown>(true);
SelectTag ranorexSelectTag = element.Element;
IList<OptionTag> options = ranorexSelectTag.Options;
IList<OptionTag> optionTagList = options.Where(tempOption => tempOption.Value!= null && tempOption.Value.Trim().Equals(optionValue.Trim(),StringComparison.OrdinalIgnoreCase)).ToList();
if(optionTagList.Count == 1)
{
OptionTag singleOptionTag = optionTagList.ElementAt(0);
singleOptionTag.Selected = true;
ranorexSelectTag.TagValue = singleOptionTag.Value;
}
}
}
}
The Program.cs
--------------------
will call the above method. Code as below.
/*
* Created by Ranorex
* User: Loganathan.sa
* Date: 25.06.2015
* Time: 20:52
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Threading;
using System.Drawing;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Reporting;
using Ranorex.Core.Testing;
namespace Test1
{
class Program
{
[STAThread]
public static int Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
}
catch (Exception e)
{
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
}
Test1.SendMailModule t = new Test1.SendMailModule();
t.SetSelectTagByOptionValue(AdditionalGroups,"gr1");
return error;
}
}
}
It give me the following error while executing. Also attached my Project for reference please.
-------------------------------------------------------------------------------------------------------------------
The type or namespace name 'Core' does not exist in the namespace 'System' (are you missing an assembly reference?) (CS0234) - C:\Users\loganathan.sa\Documents\Ranorex\RanorexStudio Projects\Test1\Test1\SelectTextbox.cs:17,14
The type or namespace name 'RepoItemInfo' could not be found (are you missing a using directive or an assembly reference?) (CS0246) - C:\Users\loganathan.sa\Documents\Ranorex\RanorexStudio Projects\Test1\Test1\SelectTextbox.cs:102,47
I have created a new .cs file (SelectTextbox) and have the following code in it.
/*
* Created by Ranorex
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
using System.Core;
namespace Test1
{
/// <summary>
/// Use this module at any position of your test suite to get informed about test runs by email.
/// This is especially useful for overnight test executions on runtime machines.
/// </summary>
[TestModule("EEE7C8D8-D950-40EF-B24A-1A9A87C0DA21", ModuleType.UserCode, 1)]
public class SendMailModule : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public SendMailModule()
{
// Do not delete SendMailModule method - a parameterless constructor is required!
}
#region Variables
string _to = "[email protected]";
[TestVariable("D089186D-7919-4023-8165-B68F9151C6A7")]
public string To
{
get { return _to; }
set { _to = value; }
}
string _from = "[email protected]";
[TestVariable("BDB3FC8C-1E51-448F-9049-AEF0B247DBDB")]
public string From
{
get { return _from; }
set { _from = value; }
}
string _subject = "Ranorex eMail Module Report";
[TestVariable("398FF772-C15C-4b91-954B-34CC636DEDC9")]
public string Subject
{
get { return _subject; }
set { _subject = value; }
}
string _serverHostName = "Smtp.gea.com";
[TestVariable("0EE4CB1E-D738-4DE8-B122-92B3CCE6F70C")]
public string ServerHostname
{
get { return _serverHostName; }
set { _serverHostName = value; }
}
string _serverPort = "25";
[TestVariable("4C6A889D-BACE-4AE1-9EEF-40EA26775574")]
public string ServerPort
{
get { return _serverPort; }
set { _serverPort = value; }
}
string _message = "Ranorex Success email configuration";
[TestVariable("D49672F4-3021-4460-96DA-2EC11AE318A8")]
public string Message
{
get { return _message; }
set { _message = value; }
}
#endregion
void ITestModule.Run()
{
}
public void SetSelectTagByOptionValue(RepoItemInfo repoInfo, string optionValue)
{
var element = repoInfo.CreateAdapter<Unkown>(true);
SelectTag ranorexSelectTag = element.Element;
IList<OptionTag> options = ranorexSelectTag.Options;
IList<OptionTag> optionTagList = options.Where(tempOption => tempOption.Value!= null && tempOption.Value.Trim().Equals(optionValue.Trim(),StringComparison.OrdinalIgnoreCase)).ToList();
if(optionTagList.Count == 1)
{
OptionTag singleOptionTag = optionTagList.ElementAt(0);
singleOptionTag.Selected = true;
ranorexSelectTag.TagValue = singleOptionTag.Value;
}
}
}
}
The Program.cs
--------------------
will call the above method. Code as below.
/*
* Created by Ranorex
* User: Loganathan.sa
* Date: 25.06.2015
* Time: 20:52
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Threading;
using System.Drawing;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Reporting;
using Ranorex.Core.Testing;
namespace Test1
{
class Program
{
[STAThread]
public static int Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
}
catch (Exception e)
{
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
}
Test1.SendMailModule t = new Test1.SendMailModule();
t.SetSelectTagByOptionValue(AdditionalGroups,"gr1");
return error;
}
}
}
It give me the following error while executing. Also attached my Project for reference please.
-------------------------------------------------------------------------------------------------------------------
The type or namespace name 'Core' does not exist in the namespace 'System' (are you missing an assembly reference?) (CS0234) - C:\Users\loganathan.sa\Documents\Ranorex\RanorexStudio Projects\Test1\Test1\SelectTextbox.cs:17,14
The type or namespace name 'RepoItemInfo' could not be found (are you missing a using directive or an assembly reference?) (CS0246) - C:\Users\loganathan.sa\Documents\Ranorex\RanorexStudio Projects\Test1\Test1\SelectTextbox.cs:102,47
You do not have the required permissions to view the files attached to this post.
-
- Certified Professional
- Posts: 74
- Joined: Mon Aug 14, 2006 7:17 pm
- Location: CH
Re: Validate - NotExists with right click disabled
Hi,
Sorry but I forgot a small information. You have to set your Target Framework to: .Net 3.5 Framework, in your project settings -> on compiling tab.
Sorry about that
Dan
Sorry but I forgot a small information. You have to set your Target Framework to: .Net 3.5 Framework, in your project settings -> on compiling tab.
Sorry about that
Dan
-
- Posts: 56
- Joined: Wed Jun 10, 2015 4:35 pm
Re: Validate - NotExists with right click disabled
Hi. Yes it was earlier set to .NET 3.5.
-
- Certified Professional
- Posts: 74
- Joined: Mon Aug 14, 2006 7:17 pm
- Location: CH
Re: Validate - NotExists with right click disabled
Hi,
And also add the Ranorex.Core Namespace, for the RepoItemInfo Object.
Regards
Dan
And also add the Ranorex.Core Namespace, for the RepoItemInfo Object.
Regards
Dan
-
- Posts: 56
- Joined: Wed Jun 10, 2015 4:35 pm
Re: Validate - NotExists with right click disabled
Hi. I am new to C#. could you please suggest how to add them. i have provided two class above(program.cs and SelectTextbox.cs)
-
- Certified Professional
- Posts: 74
- Joined: Mon Aug 14, 2006 7:17 pm
- Location: CH
Re: Validate - NotExists with right click disabled
Hi,
In the attachment I have re implement the select method you created in a own class. I removed the code lines in the Program.cs.
You can use it directly in the Recording1. Now if you want to use this method, just make an inheritance in the user code file of your recording.
If you need still help pleas let me know.
Regards
Dan
In the attachment I have re implement the select method you created in a own class. I removed the code lines in the Program.cs.
You can use it directly in the Recording1. Now if you want to use this method, just make an inheritance in the user code file of your recording.
If you need still help pleas let me know.
Regards
Dan
You do not have the required permissions to view the files attached to this post.