OpenQA.Selenium.ExecutingJavascriptTest.ShouldBeAbleToExecuteJavascriptAndReturnABasicObjectLiteral C# (CSharp) Méthode

ShouldBeAbleToExecuteJavascriptAndReturnABasicObjectLiteral() private méthode

        public void ShouldBeAbleToExecuteJavascriptAndReturnABasicObjectLiteral()
        {
            if (!(driver is IJavaScriptExecutor))
            {
                return;
            }

            driver.Url = javascriptPage;

            object result = ExecuteScript("return {abc: '123', tired: false};");
            Assert.IsTrue(result is Dictionary<string, object>, "result was: " + result.GetType().ToString());
            Dictionary<string, object> map = (Dictionary<string, object>)result;

            Dictionary<string, object> expected = new Dictionary<string, object>();
            expected.Add("abc", "123");
            expected.Add("tired", false);

            Assert.AreEqual(expected.Count, map.Count, "Expected:<" + expected.Count + ">, but was:<" + map.Count + ">");
            foreach (string expectedKey in expected.Keys)
            {
                Assert.IsTrue(map.ContainsKey(expectedKey));
                Assert.AreEqual(expected[expectedKey], map[expectedKey]);
            }
        }
ExecutingJavascriptTest