selenium获取input元素值的方法

来源:互联网 发布:excel2007重复数据筛选 编辑:程序博客网 时间:2024/06/04 18:41

selenium获取input元素的常用方法有两种:

1.利用getText()方法

eg:driver.findElement(By by).getText();

2.利用getAttribute("value")方法

eg:driver.findElement(By by).getAttribute("value")

其中,by是该输入框的定位形式

一般可以利用getText()获取输入框的内容,但是有时候获取不到输入框的值,因此可以换用getAttribute("value")的方法


原创粉丝点击