输入 - 如何在机器人框架中使用类型编号的输入标签设置值



我想将值设置为某些输入标签,但在输入标签上总是失败。

输入形式就是这样:

<div class="f-col grow-2">
    <div class="field">
        <label class="label-small">Alert ID</label>
            <input type="number" min="0" class="input-text " autocapitalize="off" autocomplete="off" name="alert_id" value="">
            <span class="msg-helper"></span>
    </div>
</div>
<div class="f-col grow-4">
    <div class="field">
        <label class="label-small">Title</label>
        <input type="text" class="input-text " autocapitalize="off" autocomplete="off" name="alert_title" value="">
        <span class="msg-helper"></span>
    </div>
</div>

这是我用来输入数字

的代码
*** Settings ***
Library  SeleniumLibrary

*** Variables ***
${FILTER_ID_LOC} =  name=alert_id
${FILTER_TITLE_LOC} =  name=alert_title

*** Keywords ***
user inputs on filter
    [Arguments]  ${title}  ${alert_id}
    Fill title  ${title}
    Fill id  ${alert_id}
Fill title
     [Arguments]  ${value}
     run keyword and continue on failure  input text  ${FILTER_TITLE_LOC}  ${value}
Fill id
    [Arguments]  ${value}
    run keyword and continue on failure  input text  ${FILTER_ID_LOC}  ${value}
*** Test Cases ***
Scenario: User inputs values on filter
    [Template]  user inputs on filter
    # title         # alr_id
    some_title      100

我使用了Chrome Webdriver,但它不起作用。机器人框架显示错误消息:

InvalidElementStateException: Message: invalid element state: Element is not currently interactable and may not be manipulated
(Session info: chrome=64.0.3282.167)
(Driver info: chromedriver=2.31.488774
(7e15618d1bf16df8bf0ecf2914ed1964a387ba0b),platform=Mac OS X 10.11.6 x86_64)

是否需要更多?我只在文档中找到input text

做什么正确的方法?

@todor是正确的。该错误是一个常见的错误,研究stackoverflow将为您提供许多解释。

在更实用,更简单的术语中,您所需元素的前面可能还有另一个元素,或者您的元素尚未准备好输入,因为它需要通过用户事件激活。很可能是焦点或单击。

因此,通常建议就是这样做。Click ElementInput Element之前遇到此问题时,没有明显的原因。

最新更新