Get Javascript result from Browser

Ask general questions here.
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


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.


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

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 (2.8 KiB) Viewed 577 times

JSON - stringify

Hope this helps.