I have a global javascript object variable. I want to get this variable by selenium webdriver in my console application.My script are in following
function Charts(x, y, name) {
this.x = x;
this.y = y;
this.name = name;
}
var xax= ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
yax= [[29.9, 71.5, 106.4, 129.2, 144, 176, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4], [24, 70, 19, 128, 148, 178, 131, 140, 211, 190, 91, 50]],
yname=["mon-data", "mon-data2"]
var jsObj =
[
new Charts(xax, yax, yname)
];
From my console application i have tried to get the object by following way:
public class ScriptObject
{
public string[] x;
public string[][] y;
public string[] name;
}
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
Wait_Label:
var obj = (object)js.ExecuteScript("return window.jsObj;");
var Listobj = js.ExecuteScript("return window.jsObj;") as List<ScriptObject>;
string obstr = JsonConvert.SerializeObject(obj);
When i take the object with casting type object then i get the value but when i take the object as type of list i got nothing it remains null.
I need to set the object values into different arrays like the following
public string[] x=obj.x;
public string[][] =obj.y;
public string[] name =obj.name;
How can extract the property of object and fulfill my purpose?