douhuan1497 2015-08-26 17:58
浏览 166
已采纳

选中没有任何属性的复选框

I'm trying to check an checkbox but it doesn't have any attributes on it to identify. I've tried to use xpath, but without success.

Bellow you can see the whole HTML code where the checkbox was inserted.

<fieldset>
  <div class="row">
    <div class="col-sm-3">
      <div class="form-group field-documento-competencia_mensal required has-success">
        <input name="Documento[competencia_mensal]" value="0" type="hidden">
        <label>
          <input id="documento-competencia_mensal" name="Documento[competencia_mensal]" value="1" type="checkbox"> Por competência mensal
        </label>
        <div class="help-block"></div>
      </div>
    </div>
    <div class="col-sm-4">
      <div style="display: none;" class="form-group field-documento-inicio_cobranca">
        <label class="control-label" for="documento-inicio_cobranca">Dia de início da cobrança</label>
        <input id="documento-inicio_cobranca" class="form-control" name="Documento[inicio_cobranca]" type="text">
        <div class="hint-block">Dia do mês seguinte em que o documento começa a ser solicitado. Pode ser negativo para indicar o próprio mês.</div>
        <div class="help-block"></div>
      </div>
    </div>
    <div class="col-sm-4">
      <div style="display: none;" class="form-group field-documento-limite_entrega">
        <label class="control-label" for="documento-limite_entrega">Dia limite para entrega do documento</label>
        <input id="documento-limite_entrega" class="form-control" name="Documento[limite_entrega]" type="text">
        <div class="hint-block">Dia do mês seguinte em que o documento passa a ser considerado pendente caso não seja entregue.</div>
        <div class="help-block"></div>
      </div>
    </div>
  </div>
  <div class="form-group field-documento-id_validade">
    <div class="row">
      <div class="col-sm-3">
        <label class="control-label" for="documento-id_validade">
          <!-- Here's the checkbox I'm trying to check -->
          <input type="checkbox"> Por Temporalidade
          <!-- Here's the checkbox I'm trying to check -->
        </label>
      </div>
      <div class="col-sm-4">
        <select style="display: none;" id="documento-id_validade" class="form-control" name="Documento[id_validade]">
          <option value="">Selecione a temporalidade</option>
          <option value="1">INDETERMINADO</option>
          <option value="2">MENSAL</option>
          <option value="3">ANUAL</option>
        </select>
      </div>
    </div>
    <div class="help-block"></div>
  </div>            
  <div class="form-group field-documento-exige_data_vencimento required">
    <input name="Documento[exige_data_vencimento]" value="0" type="hidden">
    <label>
      <input id="documento-exige_data_vencimento" name="Documento[exige_data_vencimento]" value="1" type="checkbox"> Por data de Vencimento
    </label>
    <div class="help-block"></div>
  </div>
</fieldset>

I tryed to use without success:

$I->selectOption('//div[@class="field-documento-id_validade"]/div[1]/div[1]/label/input', '1');

Can some help me with this, I'll be very grateful.

  • 写回答

1条回答 默认 最新

  • doufeng3602 2015-08-26 18:20
    关注

    I don't think that class will match.

    This should work, though it's untested:

    '//div[contains(@class, "field-documento-id_validade")]//input[@type="checkbox"]'

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog