Cast WebElement to CheckBoxElement [TestBench]

Hello guys!

I’m semi new to vaadin testbench I am facing an issue where I am locating a Checkbox using findElement(By.xpath) which returns a WebElement and if I try to use “click” method on it doesn’t get selected and if I try to cast it into a CheckBoxElement it says I cant cast a WebElement into a CheckBoxElement. How can I solve this?

Hi, you should lookup components using the $(CheckboxElement.class) instead - that will return the CheckboxElement directly. Otherwise make sure that you have TestBenchElement instead of just WebElement; then you can call wrap(CheckboxElement.class) on it.