0

Issue: I am trying to perform a click on a radio Button but it is not working it just bypass the step and perform the next step doesn't even give me any error message

enter image description here

*Intention is to click on refund Radio Button

Selenium Code: `

@Given("^User select Refund with Cash on Case Summary Page$")
public void user_select_Refund_with_Cash_on_Case_Summary_Page() throws Throwable {
WebElement radio = driver.findElement(By.xpath("//div[@class = 'col-md-12']/solvup-component-field/div/solvup-radio-type/div/div[2]/label/input"));
Actions ob = new Actions(driver);
ob.moveToElement(radio);
ob.click(radio);
Action action = ob.build();
action.perform();`

HTML:

<solvup-component _ngcontent-c2="" _nghost-c4="" id="" class=""><!----><fieldset _ngcontent-c4="" class="no-border">
        <legend _ngcontent-c4="" class="">Please select the remedy to be applied:</legend>

        <div _ngcontent-c4="" class="row component-content">
            <div _ngcontent-c4="" class="col-md-12">
                <!----><solvup-component-field _ngcontent-c4="" _nghost-c7=""><div _ngcontent-c7="">

  <!---->
  <!----><solvup-radio-type _ngcontent-c7="" _nghost-c9=""><div _ngcontent-c9="" class="ng-dirty ng-touched ng-valid">

    <solvup-label _ngcontent-c9="" _nghost-c33=""><label _ngcontent-c33="" class="control-label">
     <!----> 
</label>
<solvup-tooltip _ngcontent-c33="" _nghost-c36=""><!---->
</solvup-tooltip>
</solvup-label>

  <!----><div _ngcontent-c9="" class="radio">
      <label _ngcontent-c9="" class="">
          <input _ngcontent-c9="" type="radio" id="replace_refund_override_radio" class="ng-valid ng-dirty ng-touched">
          Replace
      </label>

  </div><div _ngcontent-c9="" class="radio">
      <label _ngcontent-c9="" class="">
          <input _ngcontent-c9="" type="radio" id="replace_refund_override_radio" class="ng-valid ng-dirty ng-touched">
          Refund
      </label>

  </div>
</div>
<solvup-hint-text _ngcontent-c9="" _nghost-c34=""><!----><p _ngcontent-c34="" class="help-block"></p>
</solvup-hint-text>
<solvup-validation-messages _ngcontent-c9="" _nghost-c35=""><!----><div _ngcontent-c35="">
    <!---->
    <!---->
</div>



<!---->

</solvup-validation-messages>


</solvup-radio-type>
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->








  <!---->
  <!---->
  <!---->
  <!---->
</div>

</solvup-component-field><solvup-component-field _ngcontent-c4="" _nghost-c7=""><div _ngcontent-c7="">

  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!----><solvup-hidden-field _ngcontent-c7="" _nghost-c23=""><div _ngcontent-c23="" class="ng-dirty ng-touched ng-valid">
    <input _ngcontent-c23="" class="form-control ng-untouched ng-pristine ng-valid" type="hidden" value="0" name="jbhifi_replace_refund_override_component.replace_outcome_hidden" id="Request_replace_outcome_hidden">
</div></solvup-hidden-field>
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->








  <!---->
  <!---->
  <!---->
  <!---->
</div>

</solvup-component-field><solvup-component-field _ngcontent-c4="" _nghost-c7=""><div _ngcontent-c7="">

  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->
  <!----><solvup-hidden-field _ngcontent-c7="" _nghost-c23=""><div _ngcontent-c23="" class="ng-dirty ng-touched ng-valid">
    <input _ngcontent-c23="" class="form-control ng-untouched ng-pristine ng-valid" type="hidden" value="" name="jbhifi_replace_refund_override_component.insurer_ext_liability_hidden" id="Request_insurer_ext_liability_hidden">
</div></solvup-hidden-field>
  <!---->
  <!---->
  <!---->
  <!---->
  <!---->








  <!---->
  <!---->
  <!---->
  <!---->
</div>

</solvup-component-field>
            </div>
        </div>

        <!---->

</fieldset>






</solvup-component>

Tried Explicit Wait , Actions , Click Does anyone have any suggestions??

0

First Verify the checkbox is Selected or not by using the isSelected() method.

Then use the below code,

WebElement radio = driver.findElement(By.xpath("//label[contains(text(),'Refund')]"));

or

WebElement radio = driver.findElement(By.xpath("//input[@id='replace_refund_override_radio']")[2]);

Use thread.sleep before locating the element

Hope this will work.

  • I used this method as well with my xpath it says True. I also used this xpath but it gives an error with xpath - unable to locate element – shreya_bhatngr Nov 23 '18 at 7:20
  • updated the answer. Try this – Prasanna venkatesh Nov 23 '18 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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