You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Karate UI时select选项选择失效问题求助

下拉框选择后提交重置及脚本执行报错问题
  • 使用Given select('select[name=data1]', '{}Option Two')选择下拉框,页面上可见select标签的选项已切换,但点击提交按钮后,选项会重置为默认值。
  • 尝试过以下两种解决方案,均无效:
    1.
    * def envName = 'env-rab' 
    * select('#environmentId', envName)
    
    1. * script("document.getElementById('environmentId').value='" + env-rab + "'")
      

编辑补充:
触发change事件后出现报错:

org.graalvm.polyglot.PolyglotException: js脚本执行两次失败:(function(){ var e = document.querySelector("select[name=cars]"); var t = "Opel"; for (var i = 0; i < e.options.length; ++i) if (e.options[i].value === t) { e.options[i].selected = true; e.dispatchEvent(new Event('change')) } })(), 错误详情: [类型: MAP, 值: {type=object, subtype=error, className=TypeError, description=TypeError: 无法读取null的属性'options'

内容的提问来源于stack exchange,提问作者dinesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 22:01:01