Selenium IE更改事件未触发 [英] Selenium IE change event not fired

查看:134
本文介绍了Selenium IE更改事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择框,上面有一个事件监听器:

I have a select box which has an event listener on it:

$(document).ready(function () {
    $('#edit-era-code-select').change(function() {
      $.ajax({ 
        url: Drupal.settings.basePath+'era/js', 
        type: 'POST',
        data: "era_code_select="+$(this).val(),
        context: document.body, 
        success: function(){
        window.location.reload(true);
      }
    });  
  });
});

在ie / ff / ...中使用它会正常工作...
使用phpunit的selenium测试我可以看到selectbox被更改但它不会触发jquery事件更改。它只发生在IE中。以下是执行该命令的代码:

It will works fine when using it in ie/ff/... When doing selenium tests using phpunit it I can see the selectbox being changed but it does not trigger the jquery event change. It only happens in IE. Here is the code that does the command:

AbstractSeleniumTestCaseIexplore::loginShib ( $user ['uid'] );
  $this->waitForElementPresent("//select[@id='edit-era-code-select']", 30000);
  $code = $this->getSelectedLabel("//select[@id='edit-era-code-select']");
  if ($code != 3333) {
    $this->select("edit-era-code-select", "label=3333");
    $this->waitForPageToLoad("30000");  
  }
  ...

有人可以帮忙吗?

推荐答案

我这样解决了。它不是最佳的,但它允许你继续并测试其他东西。

I solved it like this. Its not optimal but it allows you to continue and test other things.

$ this-> runScript($('#edit-era -code-select')。change());

这篇关于Selenium IE更改事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆