繁体   English   中英

如何在机器人框架中将html文本写入文本区域?

[英]How to write html text into text-area in robot framework?

我想将以下代码添加到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>

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.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM