I am trying to automate radio button in selenium web driver using Page object model. Below is my code explanation:
By AutomaticDataLockTimed = By.xpath("//span[@class='ant-radio']//input[@name='automaticDataLock']");
if (!((WebElement) AutomaticDataLockTimed).isSelected()) {
JSUtil.clickElementUsingBySelector(AutomaticDataLockTimed, driver);
}
}
and I am getting below error message
java.lang.ClassCastException: class org.openqa.selenium.By$ByXPath cannot be cast to class org.openqa.selenium.WebElement (org.openqa.selenium.By$ByXPath and org.openqa.selenium.WebElement are in unnamed module of loader 'app')
I have referred this link java.lang.ClassCastException: org.openqa.selenium.By$ById cannot be cast to org.openqa.selenium.WebElement
but this link did not answer my scenario.
I think it is due to casting problem in my if statement but I cannot fix.
Please help!