Exemplo n.º 1
0
        public void ShouldReturnLikeJavaScriptObjectResultWhenExecuteReturnFunctionJavaScript()
        {
            var value = GetExecutor().ExecuteScript(@"
const f = function() { return 123; }; 
f.A = 'a';
f.B = function() {
  return 345;
}
f.B.AA = 'aa';
f.B.BB = 345;
return f;");

            AssertCompatible.IsInstanceOfType(value, typeof(Dictionary <string, object>));

            var resultValue = (Dictionary <string, object>)value;

            Assert.AreEqual(2, resultValue.Count);
            Assert.AreEqual("a", resultValue["A"]);

            AssertCompatible.IsInstanceOfType(resultValue["B"], typeof(Dictionary <string, object>));
            var bValue = (Dictionary <string, object>)resultValue["B"];

            Assert.AreEqual("aa", bValue["AA"]);
            Assert.AreEqual(345L, bValue["BB"]);
        }
Exemplo n.º 2
0
        public void ShouldReturnReadOnlyCollectionWithObjectWhenReturnExecuteReturnArrayIncludeWithVariousTypes()
        {
            var value = GetExecutor().ExecuteScript("return [123, 'AAA', true, document.querySelector('input')];");

            Assert.AreEqual(typeof(ReadOnlyCollection <object>), value.GetType());
            var results = (ReadOnlyCollection <object>)value;

            Assert.AreEqual(123L, results[0]);
            Assert.AreEqual("AAA", results[1]);
            Assert.AreEqual(true, results[2]);
            AssertCompatible.IsInstanceOfType(results[3], typeof(IWebElement));
        }
Exemplo n.º 3
0
        private void IEnumerableParameterShouldPassedInArrayType(IEnumerable <object> paramValue)
        {
            var value = ExecuteParameterCheckString(new object[] { paramValue });

            Assert.AreEqual(1, value.Count);
            Assert.AreEqual("[object Array]", value[0].type);

            AssertCompatible.IsInstanceOfType(value[0].value, typeof(ReadOnlyCollection <object>));

            var values = value[0].value as ReadOnlyCollection <object>;
            var param  = paramValue.ToList();

            Assert.AreEqual(Convert.ToInt64(param[0]), values[0]);
            Assert.AreEqual(param[1], values[1]);
            Assert.AreEqual(param[2], values[2]);
        }
        public void ShouldThrowExceptionWhenReferenceTheRemovedElement()
        {
            var element = GetDriver().FindElement(By.Id("textBoxName"));

            AssertCompatible.IsInstanceOfType(element, typeof(IWebElement));
            element.SendKeys("ABC");
            GetExecutor().ExecuteScript("const elem = document.querySelector('#textBoxName'); elem.parentNode.removeChild(elem);");
            AssertCompatible.ThrowsException <StaleElementReferenceException>(() => element.SendKeys("DEF"));

            GetExecutor().ExecuteScript(@"
const elem = document.createElement('input');
elem.setAttribute('id', 'textBoxName');
document.body.appendChild(elem);");

            AssertCompatible.ThrowsException <StaleElementReferenceException>(() => element.SendKeys("DEF"));

            element = GetDriver().FindElement(By.Id("textBoxName"));
            AssertCompatible.IsInstanceOfType(element, typeof(IWebElement));
            element.SendKeys("ABC");
        }
Exemplo n.º 5
0
        public virtual void ShouldReturnWebElementWhenExecuteReturnDocumentScript()
        {
            var value = GetExecutor().ExecuteScript("return document;");

            AssertCompatible.IsInstanceOfType(value, typeof(IWebElement));
        }
Exemplo n.º 6
0
        public void ShouldReturnWebElementWhenExecuteReturnElementScript()
        {
            var value = GetExecutor().ExecuteScript("return document.querySelector('#textBoxName');");

            AssertCompatible.IsInstanceOfType(value, typeof(IWebElement));
        }