【问题标题】:How to write html text into text-area in robot framework?如何将html文本写入机器人框架中的文本区域?
【发布时间】:2018-05-11 19:20:13
【问题描述】:

我想将以下代码添加到 textarea 输入中,我应该如何使用 Robot Framework 执行此操作?

<table style="margin-top: 1em; margin-left:1em;">
    <tbody>
        <tr>
            <td><img src="/static/31bc33ac/images/48x48/orange-square.png" style="width: 48px; height: 48px; " class="icon-orange-square icon-xlg"></td>
            <td style="vertical-align:middle">
                <p><span>Started by user <a href="/user/vkatkar">Vaishali Katkar</a></span></p>
            </td>
        </tr>
        <tr>
            <td><img src="/static/31bc33ac/plugin/metrics/images/48x48/clock.png" alt="" style="width: 48px; height: 48px; margin-right:1em;"></td>
            <td style="vertical-align:middle">
                <p>This run spent 1 sec waiting in the queue.</p>
            </td>
        </tr>
        <tr>
            <td><img src="/static/31bc33ac/plugin/git/icons/git-48x48.png" alt="" style="width: 48px; height: 48px; margin-right:1em;"></td>
            <td style="vertical-align:middle"><b>Revision</b>: 861b6af99e7899d0b725459417e9fadfa25e2706
                <ul>
                    <li>develop</li>
                </ul>
            </td>
        </tr>
    </tbody>
</table>

【问题讨论】:

    标签: python selenium robotframework ui-automation


    【解决方案1】:

    HTML 字符串包含许多通常应该转义的字符。因此,将其从常规文本文件加载到变量中,然后将该变量输出到所需的 textarea 元素中会更容易。

    在下面的示例中,这是使用示例站点完成的:

    FillInForm.robot

    *** Settings ***
    Library    OperatingSystem
    Library    Selenium2Library
    
    Test Setup        Start Browser
    Test Teardown     Close Browser
    Suite Teardown    Close All Browsers
    
    
    *** Test Cases ***
    Fill Textarea with HTML code
        ${file_contents}    Get File    ./htmlcode.txt
        Input Text    name=longtext     ${file_contents}
        Sleep    3s
    
    *** Keywords ***
    Start Browser
        Open Browser    http://www.echoecho.com/htmlforms08.htm    Chrome
    

    htmlcode.txt

    Contains the HTML code you want to insert.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 1970-01-01
      • 1970-01-01
      • 2016-09-09
      • 2017-10-15
      相关资源
      最近更新 更多