Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97756

Getting the error " bound must be positive" while trying to select a random radio button

$
0
0

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.


Viewing all articles
Browse latest Browse all 97756

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>