网页上有时候遇到checkbox和radio,一般情况下这两种都是input标签,我们可以通过点击或者发送空格的方式进行选中
试验网页代码checkandradio.html:
<html>
<body>
Checkbox:
<input type="checkbox" value="cv1" name="c1">
<input type="checkbox" value="cv2">
<input type="checkbox" value="cv3" name="c1">
<input type="checkbox" value="cv4">
<p>
Radio:
<input type="radio" value="rv1" name="r1">
<input type="radio" value="rv2" name="r1">
</body>
</html>
定位:就是普通的input标签,按照正常的定位方式定位就可以,不再赘述。
下面我们用selenium选中其中的checkbox(1、2)和radio1->radio2,上代码:
from selenium import web