How do I get info back from Validate.Attribute?

Ask general questions here.
stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

How do I get info back from Validate.Attribute?

Post by stapes » Tue Sep 29, 2015 2:14 pm

I have set up Validate.Options so it no longer causes an Error:

Code: Select all

Validate.Options option = new Validate.Options(ReportLevel.Info);
			option.ExceptionOnFail=false;
Validate.Attribute(repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo, "Text", "Please enter your username and password","", option );
The trouble is, is doesn't do anything!!!

I want to take control here. If the text is not present, I want to test it against some alternative values.

How do I find out what the value of that text is, i.e. the text value in repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo?

.Text is not an option!

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: How do I get info back from Validate.Attribute?

Post by stapes » Tue Sep 29, 2015 3:00 pm

I solved my own problem.
It appears this returns True or False:

Code: Select all

if(Validate.Attribute(repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo, "Text", "Please enter your username and password","", option ))
         	{
         		ClickOKAY();
         	}

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How do I get info back from Validate.Attribute?

Post by odklizec » Tue Sep 29, 2015 3:09 pm

I think you need to use something like this to obtain the Text value from given info object...
string testValue = repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo.CreateAdapter<Ranorex.Text>(false).Text;
Then you should use the code like this...
Validate.Options option = new Validate.Options(ReportLevel.Info);
         option.ExceptionOnFail=false;
if (!Validate.Attribute(repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo, "Text", "Please enter your username and password","", option ))
{
// here you can do whatever you want in case the validation fails, e.g. read the value from given element and evaluate it...
string testValue = repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo.CreateAdapter<Ranorex.Text>(false).Text;
}
Hope this helps? ;)
Pavel Kudrys
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

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: How do I get info back from Validate.Attribute?

Post by stapes » Tue Sep 29, 2015 3:38 pm

I don't understand that reply. This is invalid sintax:

Code: Select all

string testValue = repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo.CreateAdapter<Ranorex.Text>(false).Text;  

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How do I get info back from Validate.Attribute?

Post by odklizec » Tue Sep 29, 2015 4:08 pm

Hi,

Sorry, I forgot you are working with Android ;) I guess you need to use something like this then:
string testValue = repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo.CreateAdapter<Ranorex.AndroidElement>(false).Element.GetAttributeValueText("Text");
Pavel Kudrys
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

stapes
Posts: 206
Joined: Wed Sep 16, 2015 10:55 am

Re: How do I get info back from Validate.Attribute?

Post by stapes » Wed Sep 30, 2015 10:28 am

Thank you.That worked.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How do I get info back from Validate.Attribute?

Post by odklizec » Wed Sep 30, 2015 11:28 am

You are welcome.
Pavel Kudrys
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