0

enter image description here

  1. On form, there is one binocular.
  2. On click on binocular, pop up opens.
  3. There are radio buttons on pop up. I need to click on radio buttons, it's failing.

I have tried below code but it shows error

findElement(By.id("clCategory_binacular")).click();
WebDriverWait wait=new WebDriverWait(d,10);
WebElement ele=wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='idCommonGridTableclCategory_binacularGridContainer']/tbody/tr[2]/td[3]/div/label")));
Actions builder =new Actions(d);
builder.moveToElement(ele).click().build();

Error:

Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.xpath: //*[@id='idCommonGridTableclCategory_binacularGridContainer']/tbody/tr[2]/td[3]/div/label (tried for 10 second(s) with 500 MILLISECONDS interval)
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'

Below is html code:

<tbody>
  <tr class="jqgfirstrow" role="row" style="height:auto">
    <td role="gridcell" style="height:0px;width:150px;display:none;">
    </td>
    <td role="gridcell" style=
        "height:0px;width:150px;display:none;">
    </td>
    <td role="gridcell" style="height: 0px; width: 192px;">
    </td>
    <td role="gridcell" style="height: 0px; width: 957px;">
    </td>
  </tr>
  <tr role="row"
      id="4864.33645.61824.39547" tabindex="0" class="ui-widget-content jqgrow ui-row-ltr ui-state-highlight" aria-selected="true">
    <td role="gridcell" style="display:none;" 
        aria-describedby="idCommonGridTableclCategory_binacularGridContainer_id">4864.33645.61824.39547
    </td>
    <td role="gridcell" style="display:none;" aria-describedby=
        "idCommonGridTableclCategory_binacularGridContainer_cellData">{"id":"4864.33645.61824.39547","key":"clCategory","forID":"clCategory","value":"Legal - General","label":"Legal - 
      General","name":"C2-1","categoryType":"General","type":"LEXClauseCategory"}
    </td>
    <td role="gridcell" style="" class="selectToInsertCol" aria-describedby=
        "idCommonGridTableclCategory_binacularGridContainer_">
      <div class="radioInlineMargin toggle-primary toggle-inline toggle toggle-root">
        <input type="radio" class="selectToInsertTemplate"
               name="selectToInsertTemplate" id="selectCp4864336456182439547" value="">
        <label class="control-label" for="selectCp4864336456182439547"></label>
      </div>
    </td>
    <td role="gridcell" style=
        "text-align:left;" aria-describedby="idCommonGridTableclCategory_binacularGridContainer_title">Legal - General
    </td>
  </tr>
  <tr role="row" id="4864.33645.61824.40762" tabindex="-1" class=
      "ui-widget-content jqgrow ui-row-ltr">
    <td role="gridcell" style="display:none;" aria-describedby="idCommonGridTableclCategory_binacularGridContainer_id">4864.33645.61824.40762
    </td>
    <td
        role="gridcell" style="display:none;" aria-describedby="idCommonGridTableclCategory_binacularGridContainer_cellData">
      {"id":"4864.33645.61824.40762","key":"clCategory","forID":"clCategory","value":"Legal - Standardized Deviations","label":"Legal - Standardized 
      Deviations","name":"C2-2","categoryType":"Deviation","type":"LEXClauseCategory"}
    </td>
    <td role="gridcell" style="" class="selectToInsertCol" aria-describedby=
        "idCommonGridTableclCategory_binacularGridContainer_">
      <div class="radioInlineMargin toggle-primary toggle-inline toggle toggle-root">
        <input type="radio" class="selectToInsertTemplate"
               name="selectToInsertTemplate" id="selectCp4864336456182440762" value="">
        <label class="control-label" for="selectCp4864336456182440762"></label>
      </div>
    </td>
    <td role="gridcell" style=
        "text-align:left;" aria-describedby="idCommonGridTableclCategory_binacularGridContainer_title">Legal - Standardized Deviations
    </td>
  </tr>
  <tr role="row" id="4864.33645.61824.36371" 
      tabindex="-1" class="ui-widget-content jqgrow ui-row-ltr">
    <td role="gridcell" style="display:none;" aria-describedby="idCommonGridTableclCategory_binacularGridContainer_id">
      4864.33645.61824.36371
    </td>
    <td role="gridcell" style="display:none;" aria-describedby="idCommonGridTableclCategory_binacularGridContainer_cellData">
      {"id":"4864.33645.61824.36371","key":"clCategory","forID":"clCategory","value":"Pricing and Negotiation - Standardized Deviations","label":"Pricing and Negotiation - Standardized 
      Deviations","name":"C1-2","categoryType":"Deviation","type":"LEXClauseCategory"}
    </td>
    <td role="gridcell" style="" class="selectToInsertCol" aria-describedby=
        "idCommonGridTableclCategory_binacularGridContainer_">
      <div class="radioInlineMargin toggle-primary toggle-inline toggle toggle-root">
        <input type="radio" class="selectToInsertTemplate"
               name="selectToInsertTemplate" id="selectCp4864336456182436371" value="">
        <label class="control-label" for="selectCp4864336456182436371"></label>
      </div>
    </td>
    <td role="gridcell" style=
        "text-align:left;" aria-describedby="idCommonGridTableclCategory_binacularGridContainer_title">Pricing and Negotiation - Standardized Deviations
    </td>
  </tr>
</tbody>
0

1 Answer 1

1

Use the below code

WebDriverWait wait=new WebDriverWait(driver,10);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div>label[class='control-label']"))).click();

OR can use javascriptExecutor

WebElement radio = driver.findElement(By.cssSelector("div>label[class='control-label']"));

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);
2
  • By using java script executor its able to select radio button .That's positive thing! But as soon as I click Proceed (run next step -submit pop up) it shows me error message to select radio button. Now if I manually select radio button & click submit it works
    – Pooja
    Commented Jan 9, 2019 at 10:30
  • 1
    Below code worked perfectly :Js executor & xpath combination! WebElement radio = d.findElement(By.xpath("//*[@id='4864.33645.61824.39547']/td[3]/div/label")); JavascriptExecutor js = (JavascriptExecutor)d; js.executeScript("arguments[0].click();", radio);
    – Pooja
    Commented Jan 9, 2019 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.