I am trying the select the 'Yes' 'No' options in a page,as normal 'Click()' is not working I have used JSExecutor for this! The problem is it is selecting the options, but the value was never sent as input, and the application is throwing error when I tried to continue.
Tried xpath's in diff ways!
WebElement st_1 = driver.findElement(By.id("app-select-no"));
((JavascriptExecutor)driver).executeScript("arguments[0].checked = true;", st_1);
Below is HTML
div class="form-group input-form-group col-xs-6">
<input id="app-select-no" class="form-control ng-pristine ng-untouched ng-valid ng-valid-required" type="radio" ng-value="false" ng-model="openAccount.abc" required="" name="affRadioGroup" value="false" aria-checked="true" tabindex="0" aria-required="false" aria-invalid="false"/>
<label class="field-label-radio text-bold active" ng-class="{active : openAccount.abc==false}" for="app-select-no">
<span translate-once="NO_BUTTON">No</span>
</label>
</div>
Let me see If I understood, you are trying to select "yes" or "no" on that element, but I see that the element you are clicking is an input. You also need to send the "value" to the input besides clicking the element.
Im guessing that your problem is not the click with the executeScript, but you can also try this:
WebElement st_1 = driver.findElement(By.id("app-select-no"));
((JavascriptExecutor)driver).executeScript("arguments[0].click();", st_1 );
And to send a Value to that input, yo need to do this:
driver.findElement(By.id("st_1")).sendKeys("value here");
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With