【问题标题】:How to check for the existence of a text value如何检查文本值是否存在
【发布时间】:2019-01-19 20:44:04
【问题描述】:

我对 Robot Framework 非常陌生

我需要检查网页中是否存在“注销”按钮。

<button type="button" class="ant-btn" style="width: 80px; float: right; display: inline-block;"><span>Logout</span></button>

我已经声明了变量,例如 * 变量 *

${logout_path}     xpath=//*/button[@class='ant-btn']/span

${l_path}      xpath=(//*/span[contains(text(),"Logout")])

* 测试用例 *

Get Element Attribute  xpath=(//*/button[@class='ant-btn']/span)

Element Text Should be ${logout_path}  'Logout'

以上所有语法都经过测试并失败。

如何检查网页中是否存在此文本“注销”, 我只需要检查这个字段是否存在。

请在语法方面提供帮助。

谢谢你:)

【问题讨论】:

  • 几个想法: 1. 在第一行你没有获得任何元素属性,我认为这是错误的根本原因。 2. 在第二行中,您正在比较已经包含表达式的 xpath 来检查文本,所以从我的角度来看,它没有什么意义。你可以使用关键字Page Should Contain
  • 谢谢。我添加了页面应该包含 ${l_path} 并返回“页面应该包含文本'xpath=(//*/span[contains(text(),"Logout")])' 但没有”
  • 我能够解决这个问题。使用的页面应该包含后跟睡眠命令并解决了问题。谢谢@JaPyR

标签: xpath robotframework


【解决方案1】:
Element Text Should Be    ${logout_path}    Logout

有关更多信息,请参阅: http://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Element%20Text%20Should%20Be

【讨论】:

    猜你喜欢
    • 2019-09-28
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-26
    • 1970-01-01
    • 2011-11-01
    相关资源
    最近更新 更多