Search code examples
selenium-chromedriverrobotframework

input - How to set value on input tag with type number in robot framework?


I want to set values into some input tags but always failed at input tag with type number.

The input form is like this:

<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>

And here is the code I used to input the number

*** 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

I used chrome webdriver and it didn't work. Robot Framework shows error message:

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)

Would it require something more? I only found input text in the documentation.

What is the proper way to do it?


Solution

  • @Todor is correct. The error is a common one and researching StackOverflow will provide you with a number of explanations for it.

    In more practical and simpler terms, there is likely another element in front of your desired element or your element is not yet ready to take input because it requires activation through a user event. Most likely a focus or click.

    So, often the recommendation is to do just that. Click Element before Input Element when encountering this issue for no apparent reason.