IF ELSE in robot framework with variables assignment

前端 未结 4 1316
广开言路
广开言路 2021-02-07 11:41

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\" statem

4条回答
  •  忘掉有多难
    2021-02-07 12:18

    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}   
    

    Hope this helps.

提交回复
热议问题