Note on clicking checkbox in Bootstrap button group (.NET Selenium WebDriver)
In my React app I have a Bootstrap button group with checkbox inputs inside:
When trying to automate clicking the #is-food-toggle button in a Selenium WebDriver test:
I encountered this error:
OpenQA.Selenium.ElementClickInterceptedException : element click intercepted: Element
is not clickable at point (1272, 183). Other element would receive the click:
Looking at the elements with the HTML inspector, this error message makes sense:
Checking the example in the Bootstrap docs, there is a similar thing happening:
So as a workaround I tried selecting the label with a CSS selector and clicking it instead of the input:
and this does address the issue allowing me to continue with writing the test. I try to avoid using CSS selectors targeting elements by attribute values, but I don’t really mind this case since it is using the for attribute of the input’s label which is tied to the input’s id.