jquery - Behat 不调用 jQuery
问题描述
我在 symfony 4 中使用 behat 来测试消息的发送。当您选择主题“其他”时,会从 jQuery 中显示一个新字段。当我现场测试这段代码时,没有问题。但是从 behat 开始,没有调用 jQuery。Behat 选择了正确的“其他”选项,但没有出现新字段。
这是场景中的步骤:
/**
* @Given /^I choose the subject "([^"]*)" in select "([^"]*)"$/
* @param $topic
* @param $select
*/
public function iSelectTheSubject($topic, $select)
{
$this->selectOption($select, $topic);
}
这是我的 jQuery :
(function ($) {
let selectSubject = $('#app_customer_service_taxon option');
let inputOther = $('#app_customer_service_taxonOther').parent();
let options = {
action: 'click',
html : 'other'
};
inputOther.hide();
selectSubject.on(options.action, e => {
$(e.currentTarget).html() === options.html ? inputOther.show() : inputOther.hide();
});
})(jQuery);
因此,当我开始 behat 时,它会以消息“元素不可交互”停止。就像根本没有调用 jQuery 一样。就像 selectOption 没有模拟点击一样。知道为什么吗?
解决方案
推荐阅读
- spring-session - Spring Session 重写 cookie 值并在成功的 HTTP 请求上失败
- json - Laravel API 在 windows(本地机器)和 linux 服务器(托管)中给出不同的 json 结果
- javascript - 选定的下拉值应在立即列值中更新
- python - 使用 Django Sites 设置特定于站点的静态文件夹
- python - 从 Python 运行 Kotlin 脚本并获取输出
- r - R函数仅适用于整数值?
- mongodb - Spring Boot MongoDb 仅按时间过滤
- java - 如何使用 Thymeleaf 使后退按钮根据上一页动态转到上一页?
- pdf-generation - 如何在 jsPDF 中添加可访问性标签
- python - 关闭图形或轴标题