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