我正在Visual Studio 2010下的selenium 2 webdriver中测试javascript。
有什么好的方法可以调用属于页面上当前javascript对象的方法?

最佳答案

我用它来获取隐藏元素的内部文本:
(((IJavaScriptExecutor)webDriverInstance).ExecuteScript(“ return arguments [0] .innerHTML”,this.element).ToString();

ExecuteScript的实现方式与String.Format非常相似,其中params对象作为第二个参数传入。

08-06 13:20