lundi 29 octobre 2018

How to write correct XPath or CSS?

My HTML is:

  <div tabindex="-1" role="gridcell" comp-id="376" col-id="0" class="ag-cell ag-cell-not-inline-editing ag-cell-with-height ag-cell-focus ag-cell-range-selected ag-cell-range-selected-1" style="width: 77px; left: 0px;">
    <span ref="eCellWrapper" class="ag-cell-wrapper">
      <span class="ag-selection-checkbox">
        <span class="ag-icon ag-icon-checkbox-checked"></span>
        <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
        <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
      </span>
      <span ref="eCellValue" class="ag-cell-value"></span>
    </span>
  </div>
  <span ref="eCellWrapper" class="ag-cell-wrapper">
    <span class="ag-selection-checkbox">
      <span class="ag-icon ag-icon-checkbox-checked"></span>
      <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
      <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
    </span>
    <span ref="eCellValue" class="ag-cell-value"></span>
  </span>
  <span class="ag-icon ag-icon-checkbox-checked"></span>
  <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
  <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
  <span class="ag-selection-checkbox">
    <span class="ag-icon ag-icon-checkbox-checked"></span>
    <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
    <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
  </span>
  <span ref="eCellValue" class="ag-cell-value"></span>
  <span ref="eCellWrapper" class="ag-cell-wrapper">
    <span class="ag-selection-checkbox">
      <span class="ag-icon ag-icon-checkbox-checked"></span>
      <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
      <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
    </span><span ref="eCellValue" class="ag-cell-value"></span>
  </span>

How to write correct identifier for clicking checkbox.I have row with informations, that row has checkbox I need to click to that checkbox.

This is my XPath?

var checkbox= element(by.css('div.ag-body-container>div[row id="0"]>div[col-id="0"]'));
browser.wait(ExpectedConditions.elementToBeClickable(checkbox), 5000);
checkbox.click();

It is pass, but it did not click right checkbox.It is just highlighted whole row.

My HTML:

  <div tabindex="-1" role="gridcell" comp-id="376" col-id="0" class="ag-cell ag-cell-not-inline-editing ag-cell-with-height ag-cell-focus ag-cell-range-selected ag-cell-range-selected-1" style="width: 77px; left: 0px;"><span ref="eCellWrapper" class="ag-cell-wrapper"><span class="ag-selection-checkbox"><span class="ag-icon ag-icon-checkbox-checked"></span><span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span><span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span></span><span ref="eCellValue" class="ag-cell-value"></span></span></div>
  <span ref="eCellWrapper" class="ag-cell-wrapper">
    <span class="ag-selection-checkbox">
      <span class="ag-icon ag-icon-checkbox-checked"></span>
      <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
      <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
    </span>
    <span ref="eCellValue" class="ag-cell-value"></span>
  </span>
  <span class="ag-icon ag-icon-checkbox-checked"></span>

  <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
  <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
  <span class="ag-selection-checkbox">
    <span class="ag-icon ag-icon-checkbox-checked"></span>
    <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
    <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
  </span>
  <span ref="eCellValue" class="ag-cell-value"></span>
  <span ref="eCellWrapper" class="ag-cell-wrapper">
    <span class="ag-selection-checkbox">
      <span class="ag-icon ag-icon-checkbox-checked"></span>
      <span class="ag-icon ag-icon-checkbox-unchecked ag-hidden"></span>
      <span class="ag-icon ag-icon-checkbox-indeterminate ag-hidden"></span>
    </span>
    <span ref="eCellValue" class="ag-cell-value"></span>
  </span>




Aucun commentaire:

Enregistrer un commentaire