robotframework 随机选中下拉框中的值
示例脚本:
click element id=provinceName #点击地区 省 wait until element is enabled xpath=.//*[@id='provinceNameDataGrid']/tbody/tr #等待 省份下拉框的出现 ${count1} get matching xpath count xpath=.//*[@id='provinceNameDataGrid']/tbody/tr #获取省份下拉值的数量 ${s1} evaluate random.randint(1,${count1}) random #随机一个数值 click element xpath=.//*[@id='provinceNameDataGrid']/tbody/tr[${s1}]/td #点击随机后的省份(路径中用了上面的随机数字) sleep 0.2 ${count2} get matching xpath count xpath=.//*[@id='cityNameDataGrid']/tbody/tr #获取 市 下拉值的数量 ${s2} evaluate random.randint(1,${count2}) random #随机一个数值 click element xpath=.//*[@id='cityNameDataGrid']/tbody/tr[${s2}]/td sleep 0.2 ${count3} get matching xpath count xpath=.//*[@id='districtNameDataGrid']/tbody/tr #获取 县/区 下拉值的数量 ${s3} evaluate random.randint(1,${count3}) random #随机一个数值 click element xpath=.//*[@id='districtNameDataGrid']/tbody/tr[${s3}]/td