Page 1 of 1
How do I get info back from Validate.Attribute?
Posted: Tue Sep 29, 2015 2:14 pm
by stapes
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!
Re: How do I get info back from Validate.Attribute?
Posted: Tue Sep 29, 2015 3:00 pm
by stapes
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();
}
Re: How do I get info back from Validate.Attribute?
Posted: Tue Sep 29, 2015 3:09 pm
by odklizec
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?
Re: How do I get info back from Validate.Attribute?
Posted: Tue Sep 29, 2015 3:38 pm
by stapes
I don't understand that reply. This is invalid sintax:
Code: Select all
string testValue = repo.AgileMobileApp.ConfirmLogoutNotification.DialogHeadingInfo.CreateAdapter<Ranorex.Text>(false).Text;
Re: How do I get info back from Validate.Attribute?
Posted: Tue Sep 29, 2015 4:08 pm
by odklizec
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");
Re: How do I get info back from Validate.Attribute?
Posted: Wed Sep 30, 2015 10:28 am
by stapes
Thank you.That worked.
Re: How do I get info back from Validate.Attribute?
Posted: Wed Sep 30, 2015 11:28 am
by odklizec
You are welcome.