我有一个选择框,上面有一个事件监听器:
$(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 测试时,我可以看到选择框已更改,但它不会触发jquery事件更改。它仅在IE中发生。这是执行命令的代码:
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");
}
...
有人可以帮忙吗?
最佳答案
我这样解决了。它不是最佳选择,但它可以让您继续进行测试。$this->runScript("$('#edit-era-code-select').change()");