IMAGE OF LIST OPTIONSI am trying to select a random radio button out of multiple radio buttons through the below-mentioned code:
addapp.ClickSelectUnit();
List < WebElement > options = driver.findElements(By.xpath("//input[@type='radio' and @name='application[unit_space_id]']"));
Random ran = new Random();
int index = ran.nextInt(options.size());
options.get(index).click();
But getting the error:
2019-10-31 20:24:50 ERROR TestUtilsRV:141 - bound must be positive 2019-10-31 20:24:52 INFO TestUtilsRV:134 - Quit Driver
When I run the code in Debug Perspective by putting a breakpoint at the first line it selects the random checkbox but when I run it in maven through command prompt I keep getting this error. Please help me get through this.