Get Javascript result from Browser

Ask general questions here.
manish
Posts: 1
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: 11720
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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
Stringify.png (2.8 KiB) Viewed 33 times

JSON - stringify


Hope this helps.

Sincerely,
Robert
.
Image