Get Javascript result from Browser

Ask general questions here.
manish
Certified Professional
Certified Professional
Posts: 53
Joined: Fri Aug 10, 2018 12:46 pm

Get Javascript result from Browser

Post by manish » Thu Dec 06, 2018 11:53 am

Hi,

I am testing a web application where some shapes (rectangles and squares) are drawn on a svg canvas. Once a few shapes a drawn, lets say 3 rectangles, I need to execute a javascript function to get the array containing the 3 rectangle objects from the web browser (google chrome).
I am able to execute the java script using the below code:

Code: Select all

	WebDocument webDocument = "/dom[@pageurl='URL']";

	var returnValue = webDocument.ExecuteScript("return GetWalls();");

This should, theoretically, return an array with the HTML properties for the rectangles. But I get ab object of type System.String with the value [Object.Object] which is the return type of ExcuteScript() command.

I understand that I need to somehow cast this wrapped value to Array. Any help would be appreciated.


Thanks
Manish

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Get Javascript result from Browser

Post by Support Team » Fri Dec 07, 2018 9:58 am

Hi Manish,

You would need to serialize your JS object:
Stringify.png

JSON - stringify


Hope this helps.

Sincerely,
Robert
You do not have the required permissions to view the files attached to this post.