【问题标题】:Select From List selects item but does not commit changeSelect From List 选择项目但不提交更改
【发布时间】:2017-02-06 23:12:09
【问题描述】:

使用 Robot Framework,我有一个包含多个选项的下拉菜单。当我使用 select from list 选项时,我可以看到选择被突出显示,但是当下拉菜单关闭时,值没有改变。

这是我的代码示例:

click element  id=month
select from list  xpath=//select/@name="month"  September
click button  css=button.submit

我尝试过使用 select from list by labelselect from list by value 的变体,但它们失败并显示所选列表或值不存在的错误。

按值从列表中选择示例:

click element  id=month
select from list by value  xpath=//select/@name="month"  September
click button  css=button.submit

按标签从列表中选择示例1:

click element  id=month
select from list by label  xpath=//select/@name="month"  September
click button  css=button.submit

按标签从列表中选择示例2:

click element  id=month
select from list by label  xpath=//select/@name="month"  label=September
click button  css=button.submit

在项目被“选中”但值没有改变之前,任何人都经历过这种情况?

【问题讨论】:

    标签: drop-down-menu robotframework


    【解决方案1】:

    使用以下关键字。

    将定位器作为第一个参数传递,将值作为另一个参数传递

    Select from list by label and validate
        [Arguments]    ${locator}      ${select value}
        Focus   ${locator}
        # Select from list by label 
        Select From List By Label   ${locator}  ${select value}
        # Get selected value and validate it against passed value as argument
        ${value} =  Get Selected List Label ${locator}
        Should be equal ${select value} ${value}
    

    【讨论】:

    • 感谢阿卡什!我会试试看!
    • 如果还有问题,请告诉我
    • 我所做的唯一更改是我的系统无法将 // 字符识别为注释指示符。我使用了 # 字符,效果很好。再次感谢!
    猜你喜欢
    • 2014-08-08
    • 2017-04-16
    • 2018-12-21
    • 1970-01-01
    • 1970-01-01
    • 2018-10-07
    • 1970-01-01
    • 2013-06-11
    • 1970-01-01
    相关资源
    最近更新 更多