I'm looking to create a bookmarklet that will automatically fill in values when clicked.
Currently, I can select values using:
document.getElementById('component').value="IAE-Data Agent";
document.getElementById('component').onchange();
However, this method does not display hidden fields. The javascript code on the page after the selection box seems to be responsible for displaying the field after manual selection:
showFieldWhen('cf_agents',
'component', ['IAE-Data Agent']);
I've tried various ways to execute the function but haven't been able to show those fields.
Before manual selection (when the field is hidden):
<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>
After the field is shown:
<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>
The only change is in the class attribute. Even through script, I haven't been able to achieve this.
When using a Selenium script:
Select dropdown = new Select(driver.findElement(By.id("component")));
dropdown.selectByValue("IAE-Data Agent");
I can see the hidden field getting displayed. However, running a Java application isn't practical for this task.
Are there other methods to try and show these fields? If javascript doesn't work, is it possible to execute Selenium code via bookmarklet or another approach?