【问题标题】:Keyword 'Selenium2Library.Click Element' expected 1 to 3 arguments, got 0关键字“Selenium2Library.Click Element”需要 1 到 3 个参数,得到 0
【发布时间】:2020-05-20 07:50:24
【问题描述】:

我正在尝试使用机器人框架从下面的列表中选择第一项:

<select id="organization_saml_enabled" name="organization[saml_enabled]">
   <option value="true">SAML SSO enabled</option>
   <option value="false" selected="selected">SAML SSO disabled</option>
</select>

有了这个sn-p:

Click Element  //select[@id="organization_saml_enabled"]/option[@value="true"]

我收到错误Keyword 'Selenium2Library.Click Element' expected 1 to 3 arguments, got 0.

我不明白,因为从我理解documentation 的方式来看,Click 元素需要定位器和可选的偏移量。 谁能帮我检查一下我在这里遗漏了什么。

【问题讨论】:

  • 老实说,我认为用那行代码不可能得到那个确切的错误。您绝对确定是这行特定的代码导致了这个确切的错误吗?

标签: robotframework selenium2library


【解决方案1】:

在实际定位器之前添加定位器策略(xpath:),并记住关键字和参数之间至少有两个空格:

Click Element    xpath://select[@id="organization_saml_enabled"]/option[@value="true"]

【讨论】:

  • 我还注意到,如果我使用Run Keywords 并将该关键字与另一个关键字链接,则关键字失败。这可能是导致问题的原因,所以我决定拆分关键字并单独执行它们,而不是根据特定条件链接它们。
  • Run Keywords 的情况下,您必须在关键字之间使用AND。例如:Run Keywords Keyword1 argument AND Keyword2 argument2 argument3
【解决方案2】:

不要使用 Selenium2Library,使用 SeleniumLibrary 最新版本。

【讨论】:

  • Stack Overflow 不是论坛。这不是问题的答案。
  • 这个问题也可能出现在这个问题上,因为这些版本中的关键字不同。这是一个“部分答案”///
猜你喜欢
  • 2020-10-23
  • 2015-08-24
  • 1970-01-01
  • 2019-03-18
  • 2017-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-18
相关资源
最近更新 更多