I can’t find the radiobutton element on the GLPI screen of a screen created with Formcreator to automate using Capybara and Siteprism

Asked

Viewed 50 times

0

I am working with software testing automation using Capybara with Siteprism and I am not able to click on a Radiobutton from the GLPI tool. This specific page was generated with the GLPI Formscreator plugin. I just need to select a specific radius. I’ll post the code snippet that doesn’t work.

class CadastroChamado < SitePrism::Page
  include Capybara::DSL

  element :escolhe_versao, :"#formcreator_field_2274_2"

  def cadastro_chamado()
    . . .
    escolhe_versao.click
    . . .
  end

end

This is the HTML of the page where the component is:

<div class="form-group  required line1" id="form-group-formcreator_field_2274">
    <label for="formcreator_field_2274">Informe a versão <span class="red">*</span></label>
    <div class="help-block"></div><div class="form_field">
        <input type="hidden" class="form-control" name="formcreator_field_2274" value="">
        <div class="formcreator_radios">
            <input type="radio" class="form-control" name="formcreator_field_2274" id="formcreator_field_2274_1" value="Versão 11"> 
            <label for="formcreator_field_2274_1">Versão 11</label>
            <input type="radio" class="form-control" name="formcreator_field_2274" id="formcreator_field_2274_2" value="Versão 12"> 
            <label for="formcreator_field_2274_2">Versão 12</label>
        </div>
<script type="text/javascript">
                  jQuery(document).ready(function($) {
                     jQuery("input[name='formcreator_field_2274']").on("change", function() {
                        jQuery("input[name='formcreator_field_2274']").each(function() {
                           if (this.checked == true) {
                              formcreatorChangeValueOf (2274, this.value);
                           }
                        });
                     });
                  });
</script>
    </div>
</div>

1 answer

0


I found the way to click on the element using Siteprism and Capybara. I had to search for the radiobutton text inside the radio label. Follow the changed and functional code:

class CadastroChamado < SitePrism::Page
  include Capybara::DSL

  element :escolhe_versao, :css, "label[for='formcreator_field_2274_2']", :text=>"Versão 12"

  def cadastro_chamado()
    . . .
    escolhe_versao.click
    . . .
  end

end

Browser other questions tagged

You are not signed in. Login or sign up in order to post.