无法在 Robot Framework 中获取 <Strong> 标签以外的数据

Not able to fetch data besides <Strong> tag in Robot Framework

我正在尝试获取 strong 标记后的数值,因为它不是网络元素,我无法将值 123456789 获取到变量中: 如果我使用 Get Text xpath=//*[@id='referral-or-navinet-reference-number'] 那么结果是“Referral #: 123456789” 请帮助我只获取变量的数值。

HTML代码:

<td class="normal-text" id="referral-or-navinet-reference-number" align="right">
    <strong>Referral #:</strong> 123456789
</td>

可以直接使用python

split方法

赞 :-

x.split(":") // x 是你的 gettext 的字符串变量

http://www.tutorialspoint.com/python/string_split.htm

http://www.pythonforbeginners.com/dictionary/python-split

希望对您有所帮助:)

如果您的 td 仅包含想要的文本作为内容文本,您可以使用以下 xpath:

//*[@id='referral-or-navinet-reference-number']/text()

这应该 return 123456789(可能有一些空格)

您可以使用给定的 xpath :

//td[@id="referral-or-navinet-reference-number"]/text()[标准化-space()]