selenium - 如何测试模糊 - Firefox Selenium 驱动程序?

标签 selenium firefox selenium-firefoxdriver firefox-driver

我正在使用 Selenium 2.24 Firefox 驱动程序测试输入框的 模糊 事件。目前,经过我sendKeys对于输入框,我让 selenium 单击触发输入框模糊的另一个区域。

但是,我认为这不是一个好方法,有人知道更好的测试方法吗?

非常感谢。

最佳答案

我做了一个小小的调查。我发现 selenium 2.0 不支持火灾事件。见 details .
所以这段代码对我有用:

 driver.get("http://www.onliner.by/");

        String cssSelctr= "div.b-top-search-box input[id=\"g-search-input\"]";
        WebElement testElement=driver.findElement(By.cssSelector(cssSelctr));
        testElement.sendKeys("fvsdfs");

        JavascriptExecutor js = (JavascriptExecutor) driver;
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("var x = $(\'"+cssSelctr+"\');");
        stringBuilder.append("x.blur();");
        js.executeScript(stringBuilder.toString());

现在希望这对你有帮助)

关于selenium - 如何测试模糊 - Firefox Selenium 驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12337046/

相关文章:

python - Scrapy 与多处理兼容吗?

火狐扩展 SDK : how to access address bar

python - Linux 上缺少 Selenium Firefox 配置文件

java - Tomcat 中的 Selenium Chrome 驱动程序为什么不工作?

java - Logback 输出到 mySQL

javascript - 为什么 CSS 悬停动画与 Firefox 的工作方式不同?

javascript - parentNode 在 Firefox 中返回一个 window 对象,在 Chrome 中返回一个 div 对象

java - SecurityError : CSSStyleSheet. cssRules getter:使用 Selenium Firefox 读取 CSS 样式表时不允许访问跨源样式表错误

java - Selenium 将焦点切换到选项卡,单击链接后打开该选项卡