cancel
Showing results for 
Search instead for 
Did you mean: 

Verify SuccessfulMessage

SOLVED
Highlighted
Occasional Contributor

Verify SuccessfulMessage

I have to verify this Message "'Saved and published successfully!'"in my page .if not show error Message.I inclueded my code but not working.Please help me to this code:

function objCheckSMessage() {
fMessage = "Test Failed";
var successfulMessage = objPages().FindChild(['Name', 'idStr'],['TextNode("validationSuccessMsg")', "validationSuccessMsg"], 20);
var sMessage = successfulMessage.contentText;
if (sMessage == 'Saved and published successfully!' ) {
Log.Message("Addcustomer:" + sMessage); 
} else {
Log.Message("Error Message: " +fMessage );

}

}

1 ACCEPTED SOLUTION

Accepted Solutions
Community Leader

Re: Verify SuccessfulMessage

Would you mind posting a screenshot of your object tree.  What error message does TC give you ?

 

Your 'Name' Property of 'TextNode("ValidationSuccessMsg")' doesn't look right.

 

Perhaps you are looking at something like 

var props = ['ObjectType','ObjectIdentifier'];
var vals = ['TextNode','validationSuccessMsg'];
containerObj.FindChild(props,vals,20);

What is objPages() ?  It is possible that it's not something valid for performing a Find on


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

View solution in original post

6 REPLIES 6
Community Leader

Re: Verify SuccessfulMessage

Would you mind posting a screenshot of your object tree.  What error message does TC give you ?

 

Your 'Name' Property of 'TextNode("ValidationSuccessMsg")' doesn't look right.

 

Perhaps you are looking at something like 

var props = ['ObjectType','ObjectIdentifier'];
var vals = ['TextNode','validationSuccessMsg'];
containerObj.FindChild(props,vals,20);

What is objPages() ?  It is possible that it's not something valid for performing a Find on


-------------------------------------------------
Standard syntax disclaimers apply
Regards,

View solution in original post

Occasional Contributor

Re: Verify SuccessfulMessage

objPages() is intialize browser and page.as requested I attached screenshot my object tree.

Occasional Contributor

Re: Verify SuccessfulMessage

Tc doest not shows proper messages.

Community Leader

Re: Verify SuccessfulMessage

The find method can only be applied to a TC "object".  I assume objPages() is a method ? Could you show us what it returns ?  Is it Page object ?  Does objPages().Exists return true or false ? e.g.

 

var returnedObject = pageObj();

if(returnedObject.Exists)
{
 Log.Message("It Exists, you can do a find");
}
else
{
Log.Error("The returned object doesn't exist");
}

You can change your "ObjectIdentifier" property to an idStr property.  The Value is still the same "validationSuccessMsg"


-------------------------------------------------
Standard syntax disclaimers apply
Regards,
Occasional Contributor

Re: Verify SuccessfulMessage

showing page object method

function objPages() {
var page = Sys.Browser("*").Page("*");
return page;
}

 

Community Leader

Re: Verify SuccessfulMessage


@Urmikhan wrote:

var page = Sys.Browser("*").Page("*");
return page;


Thats a risky bit of code.  You have no guarantee that you will even be looking at the page you are intending to find.  It's efectively saying bring me any page you can find - no matter what it's called. 

 

Have you tested the .Exists property on the returned value yet ?


-------------------------------------------------
Standard syntax disclaimers apply
Regards,