user1120260
user1120260

Reputation: 385

To to select radio button in Protractor

I got the following codes as shown below:

<div class="inner">
    <h1> SOme text here</h1>
    <app-secondpart>
        <div class="class2">
            <label> some label</label>
            <label> 
                <input id="yes" type="radio">
                "Yes"
            </label>
            <label> 
                <input id="no" type="radio">
                "No"
            </label>
        </div>
    </app-secondpart>
</div>

I wish to select/click "Yes" with this code "element(by.id("yes")).click();" But when running the app, I got this error "Failed: element not interactable."

I am new to Protractor by the way.

Upvotes: 1

Views: 323

Answers (1)

Infern0
Infern0

Reputation: 2814

Try the following js click on button.

export async function jsClickButton() {

    try {
        let btn = element(By.id('yes'));
        await browser.executeScript('arguments[0].click()', btn).then(async() => {
            console.log('Btn has been clicked.');
        });
    } catch (error) {
        console.log('Button is not clickable due ' + error);
    }
}
  • Second solution is click on the label element.

Upvotes: 1

Related Questions