获取元素text的时候,经常会遇到获取 input 元素类型的文本内容,有时候经常看不见输入的字符的内容,这时候需要获取输入后的内容很难获取到,以下有两种方法能获取到能输入字符的方法,亲测
=
方法1:
${pos} get value //input[@id=“posName”]
=
方法2:
${posn} get element attribute //input[@id=“posName”] value
正常获取文本字符
get text
就可以
官方文档: Name: **Get Value** [返回定位器标识的元素的值属性。 有关定位器语法的详细信息,请参阅“定位元素”部分。] Source: Selenium2Library Arguments: [ locator ] Returns the value attribute of element identified by locator. See the `Locating elements` section for details about the locator syntax.
Name:
Get Element Attribute
[使用显式属性参数。]
Source:
Selenium2Library
Arguments:
[ locator | attribute=None ]
Returns value of attribute from element locator.
See the Locating elements
section for details about the locator syntax.
Example:
Passing attribute name as part of the locator is deprecated since Selenium2Library 3.0. The explicit attribute argument should be used instead.
有什么疑问可以私聊讨论