Scenario:
I am automating a feature where I need to click on the radio button but after many attempts, it didn't work. So I checked with isDisplayed
, isEnabled
and isSelected
.
Upon execution it was found that the isDisplayed
and isEnabled
are false and isSelected
is true. So, in this case, how can I perform click on this radio button.
Automation using: Cucumber + Selenium with java.
Below is the detailed information:
HTML Code:
<solvup-radio-type _ngcontent-c7="" _nghost-c9=""><div _ngcontent-c9="" class="ng-invalid ng-dirty ng-touched">
<solvup-label _ngcontent-c9="" _nghost-c33=""><label _ngcontent-c33="" class="control-label">
Which Remedy are you authorising? <!----><span _ngcontent-c33="" class="required-mark">*</span>
</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="" class="">
<!---->
<!---->
</div>
Selenium code:
@Given("^User Overriddes Refund$")
public void user_Overriddes_Refund() throws Throwable {
Thread.sleep(6000);
driver.findElement(By.xpath("//div[@class ='radio']/following-sibling::div/label/input")).isDisplayed();
driver.findElement(By.xpath("//div[@class ='radio']/following-sibling::div/label/input")).isSelected();
driver.findElement(By.xpath("//div[@class ='radio']/following-sibling::div/label/input")).isEnabled();
//new WebDriverWait(driver, 50).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@class ='radio']/following-sibling::div/label/input")));
WebElement radio = driver.findElement(By.xpath("//div[@class ='radio']/following-sibling::div/label/input"));
Actions ob = new Actions(driver);
ob.moveToElement(radio);
ob.click(radio);
Action action = ob.build();
action.perform();
//List<WebElement> li = driver.findElements(By.id("replace_refund_override_radio"));
//li.get(1).click();
}
Does anyone have any suggestion on this?