I'm learning to read javascript variable using Selenium WebDriver (latest version). Sometimes it works, sometimes not. Below is my try on whoscored.com and it keeps showing error
using (IWebDriver driver = new ChromeDriver())
{
driver.Navigate().GoToUrl("http://www.whoscored.com/Regions/81/Tournaments/3/Germany-Bundesliga");
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
var tournament = wait.Until(ExpectedConditions.ElementExists(By.Id("tournament-fixture-wrapper")));
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
var obj = (object)js.ExecuteScript("return window.allRegions;"); //always return error 'Additional information: Unable to cast object of type 'System.Int64' to type 'System.String'.
}