I'm writing testcases to select 7 radio buttons. While select the radio button it displays run time error. I have tried with below code : public void selecttemplate() { List<WebElement> rdBtn = driver.findElements(By.name("Template_Type")); int size=rdBtn.size(); for(int i=0;i<size;i++) { String val=rdBtn.get(i).getAttribute("value"); if(val.equals("Documents")) { rdBtn.get(i).click(); break; } } WebElement save=driver.findElement(By.name("register-button")); save.submit(); } Below is error snap: [![enter image description here][1]][1] [![enter image description here][2]][2] [1]: https://i.sstatic.net/EKz4C.png [2]: https://i.sstatic.net/sqQp2.png