public ExecuteScript ( string script ) : object | ||
script | string | The JavaScript code to execute. |
리턴 | object |
public void ShouldUnwrapElementArgsWhenCallingScripts() { Mock <IExecutingDriver> executingDriver = mocks.CreateMock <IExecutingDriver>(); executingDriver.Expects.One.Method(_ => _.FindElement(null)).With(By.Id("foo")).WillReturn(mockElement.MockObject); executingDriver.Expects.One.Method(_ => _.ExecuteScript(null, null)).With("foo", new[] { mockElement.MockObject }).WillReturn("foo"); EventFiringWebDriver testedDriver = new EventFiringWebDriver(executingDriver.MockObject); IWebElement element = testedDriver.FindElement(By.Id("foo")); try { testedDriver.ExecuteScript("foo", element); } catch (Exception e) { // This is the error we're trying to fix throw e; } }
public void ShouldUnwrapElementArgsWhenCallingScripts() { Mock <IExecutingDriver> executingDriver = new Mock <IExecutingDriver>(); executingDriver.Setup(_ => _.FindElement(It.Is <By>(x => x.Equals(By.Id("foo"))))).Returns(mockElement.Object); executingDriver.Setup(_ => _.ExecuteScript(It.IsAny <string>(), It.IsAny <object[]>())).Returns("foo"); EventFiringWebDriver testedDriver = new EventFiringWebDriver(executingDriver.Object); IWebElement element = testedDriver.FindElement(By.Id("foo")); try { testedDriver.ExecuteScript("foo", element); } catch (Exception e) { // This is the error we're trying to fix throw e; } }
public void ShouldUnwrapElementArgsWhenCallingScripts() { IExecutingDriver executingDriver = mocks.NewMock <IExecutingDriver>(); Expect.Once.On(executingDriver).Method("FindElement").With(By.Id("foo")).Will(Return.Value(mockElement)); Expect.Once.On(executingDriver).Method("ExecuteScript").With("foo", new[] { mockElement }).Will(Return.Value("foo")); EventFiringWebDriver testedDriver = new EventFiringWebDriver(executingDriver); IWebElement element = testedDriver.FindElement(By.Id("foo")); try { testedDriver.ExecuteScript("foo", element); } catch (Exception e) { // This is the error we're trying to fix throw e; } }
public void ShouldUnwrapElementArgsWhenCallingScripts() { IExecutingDriver executingDriver = mocks.NewMock<IExecutingDriver>(); Expect.Once.On(executingDriver).Method("FindElement").With(By.Id("foo")).Will(Return.Value(mockElement)); Expect.Once.On(executingDriver).Method("ExecuteScript").With("foo", new[] { mockElement }).Will(Return.Value("foo")); EventFiringWebDriver testedDriver = new EventFiringWebDriver(executingDriver); IWebElement element = testedDriver.FindElement(By.Id("foo")); try { testedDriver.ExecuteScript("foo", element); } catch (Exception e) { // This is the error we're trying to fix throw e; } }