Show hidden fields after selecting particular option

Viewed 78

I want to write a bookmarklet kind of thing that will execute on a click and autofill the values.

I am able to select the values through

document.getElementById('component').value="IAE-Data Agent";
document.getElementById('component').onchange();

but it does not displayes hidden fields.This is the javascript code written in page after that select box which i think displayes the field after manually selecting the box.

showFieldWhen('cf_agents',
            'component', ['IAE-Data Agent']);

I tried executing the function and many other ways still it does not show those field.

Before manually selecting(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>

Only the class atrribute changes.I tried many ways but still throught script i ma not able to do it.

When i am using selenium script

Select dropdown = new Select(driver.findElement(By.id("component")));
    dropdown.selectByValue("IAE-Data Agent");

i am able to see the hidden field getting displayed.But it is not feasible because i don't want to run a java application to do the task.

What other ways can be tried to show these fields.If javascript code dont work is it possible to execute selenium code through bookmarklet or some other way to get it done.

1 Answers
Related