问题描述
我正在使用selenium WebDriver语法。我知道,在基于selenium server的语法中,您可以通过执行以下操作来触发javascript事件:
I'm using selenium WebDriver syntax. I know, that in selenium server-based syntax, you can fire an javascript event by doing:
Selenium selenium = new DefaultSelenium("localhost", server.getPort(),
"*iexplore", "http://www.eviltester.com");
selenium.fireEvent("lteq30", "blur");
如何在使用WebDriver创建的应用程序中执行相同操作(例如,FirefoxDriver)?
how do I do the same in an application, created with WebDriver (for example, FirefoxDriver)?
推荐答案
不幸的是,Selenium WebDriver设计师明确地此功能。
Unfortunately the Selenium WebDriver designers explicitly decided not to include this functionality in Selenium 2.
话虽如此,你可以执行任何javascript代码你要。因此,您应该查看如何使用javascript 触发事件。请查看以获取灵感。
With that said, you can execute any javascript code you want. Thus you should look into how to fire events with javascript. Take at look at this StackOverflow question for inspiration.
然后你可以这样做:
FirefoxDriver driver = new FirefoxDriver();
driver.ExecuteScript("[your fire event javascript code]");
我确定你可以创建一个包装函数来基本上完成与<$ c $相同的事情c> fireEvent 。
I'm sure you could create a wrapper function to basically accomplish the same thing as fireEvent
.
这篇关于如何在硒中解雇JS事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!