I want to click radio button in my automation tests. Even though radio buttons are visible on the page, unselected ones have displayed:false
property. Selenide somehow can not click if html object has displayed:false
property. The error is : Element should be visible {By.id: radio_btn_id}
Here is my radio button:
<input class="radio_class" id="radio_btn_id" name="radio_btn_name" type="radio" value="12" displayed:false></input>
What I have tried for removing the property and none of them are working
SelenideElement element = $(By.id(id));
Selenide.executeJavaScript("document.getElementById('radio_btn_id').removeAttribute('displayed:false')", element);
Selenide.executeJavaScript("document.getElementById('radio_btn_id').removeAttribute(\"displayed:false\")", element);
Selenide.executeJavaScript("jQuery('select:not(:visible)').css('display','block')", element);
I tried to remove selected:true
property and it worked. I don't know why it does not work for displayed:false
. Do any of you have an idea ?
[EDIT]
Accepted answer is Selenium
version. In Selenide
it is more clean and simple :
SelenideElement element = $(By.id(id));
Selenide.executeJavaScript("document.getElementById('"+ id+ "').click();", element);
[SOLUTION]