【问题标题】:Robot Framework Text Field Clearing and Inputting机器人框架文本字段清除和输入
【发布时间】:2016-11-15 05:28:48
【问题描述】:

我正在使用机器人框架自动化网页。页面有不寻常的文本字段接收自动输入(不是占位符值),以防 Enter 因无效值而被点击。

这是文本字段:

<div class="bound_value">
	<input id="ember475" size="5" type="text" class="ember-view ember-text-field">
	<input id="ember476" type="checkbox" class="ember-view ember-checkbox">
</div>

我已尝试使用 Input Text 以及 Press Key 进行处理。 我是一个初学者程序员,所以请原谅我的措辞。

  • 使用 输入文本:行为就像我点击了该字段一样, 清空内容,回车,输入数值。

  • 使用 Press Key 的行为就像我点击了添加字段 只是输入了我已经包含的内容。

清除元素文本+按键输入文本的工作方式相同。

我需要一种方法来点击文本字段,删除内容,不按回车,输入文本,然后按回车。

如何使用 RIDE 自定义库来做到这一点?

提前感谢您的努力。

【问题讨论】:

    标签: input automation textfield robotframework selenium2library


    【解决方案1】:

    您是否尝试过使用关键字清除元素文本

     Clear Element Text  xpath=//input[@id='ember475']
    

    更多信息在这里http://robotframework.org/Selenium2Library/doc/Selenium2Library.html#Clear%20Element%20Text

    【讨论】:

      【解决方案2】:

      这可能对你有用:

      *** Keywords ***
      Clear Field Of Characters
          [Arguments]    ${field}    ${character count}
          [Documentation]    This keyword pushes the delete key (ascii: \8) a specified number of times in a specified field.
          :FOR    ${index}    IN RANGE    ${character count}
          \    Press Key    ${field}    \\8
      
      Input Into Text Field
          [Arguments]    ${field}    ${text}
          [Documentation]    Keyword is just an input text keyword. That clears the text field dynamically.
          ${field text}=    Get Value    ${field}
          ${field text length}=    Get Length    ${field text}
          Clear Field of Characters    ${field}    ${field text length}
          Press Key    ${field}    ${text}
      

      一旦输入了所有文本,这不会做的部分是在字段中按回车键。您可以将以下内容附加到末尾,或者之后在单独的电话中完成。

      Press Key    ${field}    \\13    #I believe 13 is the ascii for carriage return, \n may work as well.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-04-30
        • 1970-01-01
        • 1970-01-01
        • 2016-09-09
        • 1970-01-01
        • 1970-01-01
        • 2020-03-20
        • 2021-01-13
        相关资源
        最近更新 更多