document.getElementById('component').value="IAE-Data Agent";
document.getElementById('component').onchange();
但是它不显示隐藏字段。这是在选择框后面编写的Javascript代码,我认为手动选择框后显示该字段。
showFieldWhen('cf_agents',
'component', ['IAE-Data Agent']);
我尝试执行该函数和其他多种方法,但仍然无法显示这些字段。
在手动选择之前(当该字段被隐藏)
<th class="field_label bz_hidden_field" id="field_label_cf_agents">
<label for="cf_agents">
<a title="A custom Free Text field in this installation of Bugzilla." class="field_help_link" href="page.cgi?id=fields.html#cf_agents">Agent Class Name:</a>
</label>
</th>
字段显示后:
<th class="field_label" id="field_label_cf_agents">
<label for="cf_agents">
<a title="A custom Free Text field in this installation of Bugzilla." class="field_help_link" href="page.cgi?id=fields.html#cf_agents">Agent Class Name:</a>
</label>
</th>
只有class属性发生了变化。我尝试了很多方法,但是通过脚本仍然无法实现。
当我使用selenium脚本时
Select dropdown = new Select(driver.findElement(By.id("component")));
dropdown.selectByValue("IAE-Data Agent");
我可以看到隐藏字段被显示出来了。但这样做并不可行,因为我不想运行一个Java应用程序来执行这个任务。
还有哪些其他方法可以尝试显示这些字段?如果JavaScript代码无法使用,是否可以通过书签脚本或其他方式执行Selenium代码来完成此操作呢?