<tfoot id='IpuDr'></tfoot>

        • <bdo id='IpuDr'></bdo><ul id='IpuDr'></ul>

        <small id='IpuDr'></small><noframes id='IpuDr'>

      1. <i id='IpuDr'><tr id='IpuDr'><dt id='IpuDr'><q id='IpuDr'><span id='IpuDr'><b id='IpuDr'><form id='IpuDr'><ins id='IpuDr'></ins><ul id='IpuDr'></ul><sub id='IpuDr'></sub></form><legend id='IpuDr'></legend><bdo id='IpuDr'><pre id='IpuDr'><center id='IpuDr'></center></pre></bdo></b><th id='IpuDr'></th></span></q></dt></tr></i><div id='IpuDr'><tfoot id='IpuDr'></tfoot><dl id='IpuDr'><fieldset id='IpuDr'></fieldset></dl></div>
        <legend id='IpuDr'><style id='IpuDr'><dir id='IpuDr'><q id='IpuDr'></q></dir></style></legend>
      2. 带有变量分配的机器人框架中的 IF ELSE

        时间:2023-09-12
          <legend id='gFoJt'><style id='gFoJt'><dir id='gFoJt'><q id='gFoJt'></q></dir></style></legend>
            <i id='gFoJt'><tr id='gFoJt'><dt id='gFoJt'><q id='gFoJt'><span id='gFoJt'><b id='gFoJt'><form id='gFoJt'><ins id='gFoJt'></ins><ul id='gFoJt'></ul><sub id='gFoJt'></sub></form><legend id='gFoJt'></legend><bdo id='gFoJt'><pre id='gFoJt'><center id='gFoJt'></center></pre></bdo></b><th id='gFoJt'></th></span></q></dt></tr></i><div id='gFoJt'><tfoot id='gFoJt'></tfoot><dl id='gFoJt'><fieldset id='gFoJt'></fieldset></dl></div>

            <small id='gFoJt'></small><noframes id='gFoJt'>

            • <tfoot id='gFoJt'></tfoot>

                <tbody id='gFoJt'></tbody>

                  <bdo id='gFoJt'></bdo><ul id='gFoJt'></ul>

                  本文介绍了带有变量分配的机器人框架中的 IF ELSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要在机器人框架中有条件地执行一些关键字,但我不知道该怎么做,它不起作用.我尝试了很多选项,但我想我的IF-ELSE"语句完全错误..

                  I need to execute some keywords conditionally in robot framework, but I dont know how to do it, it does not work. I tried many options, but I guess I have the "IF-ELSE" statement completely wrong..

                  Choose Particular Filter ${FILTER} And Uncheck All Values
                      ${bool}=   is filter opened   ${AVAILABLE FILTERS}   ${FILTER}
                      ${uncheck_all_button}=    run keyword  if    "${bool}" == "True"   uncheck all in filter  ${AVAILABLE FILTERS}   ${FILTER}
                      ...                       click element   ${uncheck_all_button}
                      ...                       ELSE
                      ...                       Set variable    ${particular_filter}:    find particular filter   ${AVAILABLE FILTERS}  ${FILTER}
                      ...                       click element   ${particular_filter}
                      ...                       Set variable    ${uncheck_all_button}:   uncheck all in filter  ${AVAILABLE FILTERS}   ${FILTER}
                      ...                       click element   ${uncheck_all_button}
                  

                  它失败了:Variable '${particular_filter}' not found.但是如果我运行它,它甚至不应该去 ELSE 分支,因为 ${bool} 是 True...我的自定义函数 is filter opens 只是检查过滤器是否已经打开 - 如果是,则返回 True.我的自定义函数 uncheck all in filter 只返回uncheck all"按钮的 XPATH.我的自定义函数 find specific filter 返回filter dropdown"按钮的 XPATH.在这整个关键字中,我需要检查过滤器下拉菜单是否已经打开 - 如果是,那么我必须直接点击 ${uncheck_all_button},否则如果过滤器下拉菜单尚未打开,我需要首先点击过滤器本身 ${particular_filter} 然后我可以点击 ${uncheck_all_button}

                  It fails with: Variable '${particular_filter}' not found. But in case I run it it should not even go to ELSE branch because ${bool} is True... My custom function is filter opened just checks whether filter is already opened - if so, returns True. My custom function uncheck all in filter just returns XPATH of "uncheck all" button. My custom function find particular filter returns XPATH of "filter dropdown" button. In this whole keyword I need to check whether the filter dropdown is already opened - if so, then I have to click directly on ${uncheck_all_button}, else if the filter dropdown is not opened yet, I need to first click on the filter itself ${particular_filter} and after that I can click on ${uncheck_all_button}

                  我还尝试了运行关键字"这一行:

                  I also tried the "run keyword" line to have like this:

                  ${uncheck_all_button}=    run keyword  if    "${bool}" == "True"    Set Variable    uncheck all in filter    ${AVAILABLE FILTERS}    ${FILTER}
                  

                  或者这个:

                  run keyword  if    "${bool}" == "True"   ${uncheck_all_button}=    uncheck all in filter    ${AVAILABLE FILTERS}    ${FILTER}
                  

                  我也试过 ${bool} == "True"${bool} == True

                  但没有什么真正起作用,仍然是同样的错误:(

                  But nothing really works, still the same error :(

                  非常感谢您的帮助!

                  推荐答案

                  在每个块中使用带有多个语句的 IF/THEN/ELSE 在 Robot 中不起作用(或者我想您将不得不使用运行关键字",但是将变得不可读).所以我会用这种方式重构你的代码:

                  Having IF/THEN/ELSE with multiple statements in each block does not work in Robot (or you would have to use "Run Keywords" I suppose, but that would become unreadable). So I would refactor your code this way:

                  Choose Particular Filter ${FILTER} And Uncheck All Values
                      ${is_filter_opened}=   is filter opened   ${AVAILABLE FILTERS}   ${FILTER}
                      run keyword  if    ${is_filter_opened}    actions_when_unchecked
                      ...                ELSE  actions_when_checked
                  
                  actions_when_unchecked
                      uncheck all in filter  ${AVAILABLE FILTERS}   ${FILTER}
                      click element   ${uncheck_all_button}
                  
                  actions_when_checked    
                      ${particular_filter}:    find particular filter   ${AVAILABLE FILTERS}  ${FILTER}
                      click element   ${particular_filter}
                      ${uncheck_all_button}:   uncheck all in filter  ${AVAILABLE FILTERS}   ${FILTER}
                      click element   ${uncheck_all_button}   
                  

                  希望这会有所帮助.

                  这篇关于带有变量分配的机器人框架中的 IF ELSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 selenium 2 检查网页上是否存在某些文本 下一篇:当我尝试安装 readline-6.2 时出现 gcc 错误

                  相关文章

                  最新文章

                • <small id='vj1uA'></small><noframes id='vj1uA'>

                • <i id='vj1uA'><tr id='vj1uA'><dt id='vj1uA'><q id='vj1uA'><span id='vj1uA'><b id='vj1uA'><form id='vj1uA'><ins id='vj1uA'></ins><ul id='vj1uA'></ul><sub id='vj1uA'></sub></form><legend id='vj1uA'></legend><bdo id='vj1uA'><pre id='vj1uA'><center id='vj1uA'></center></pre></bdo></b><th id='vj1uA'></th></span></q></dt></tr></i><div id='vj1uA'><tfoot id='vj1uA'></tfoot><dl id='vj1uA'><fieldset id='vj1uA'></fieldset></dl></div>
                    <bdo id='vj1uA'></bdo><ul id='vj1uA'></ul>

                    1. <tfoot id='vj1uA'></tfoot>
                      <legend id='vj1uA'><style id='vj1uA'><dir id='vj1uA'><q id='vj1uA'></q></dir></style></legend>