文章来源: 敏而好学论坛 嗨学网www.piaodoo.com 欢迎大家相互学习
chrome 右键有copy xpath地址
但是有些时候获取的可能不对
可以自己用代码验证一下
如果还是不行 可以考虑从源码当中取出来
趁热打铁,使用前一篇文章中 XPath 节点来定位HTML 页面。
HTML文件如下(您可以将其拷贝,保存成html文件,跟我笔者实验):
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Storm</title> </head> <body> <h1 id="h1" name="hname" class="cname">这是一个h1标签</h1> <form> 文本域1:<input type="text" name="first_name"> <br> 文本域2:<input type="text" name="last_name"> </form> <form> 密码字段:<input type="password" name="password"> </form> <form> 单选按钮1: <input type="radio" name="radio1" value="nan">male <input type="radio" name="radio1" value="nv">female </form> <form> 宠物: <input type="checkbox" name="cw">猫 <input type="checkbox" name="cw">狗 <input type="checkbox" name="cw">兔子 </form> </body> </html>
1、节点
上面的HTML文件