标签:
1.原始需求,选择省份后,相应的城市会自动加载
2.代码实现
Random random = new Random(); Select slp = new Select(dr.findElement(By.id("province"))); int psize = slp.getOptions().size()-1; int p = random.nextInt(24); slp.selectByIndex(p+1); Select slc = new Select(dr.findElement(By.id("city"))); int size = slc.getOptions().size()-1; int c = random.nextInt(size); slc.selectByIndex(c+1);
3.注意要过滤掉“请选择”这个选项,所有要在选择的时候+1
标签:
原文地址:http://www.cnblogs.com/qiaoyeye/p/5064177.html