Select From List selects item but does not commit change

假如想象 提交于 2019-12-23 05:29:21

问题


Using Robot Framework, I have a dropdown with multiple options. When I use the select from list option I can see the selection become highlighted, but when the dropdown closes, the value is not changed.

Here is a sample of my code:

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

I have tried variants of this with the select from list by label and select from list by value, and they fail with error stating the selected list or value does not exist.

Select from list by value example:

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

Select from list by label example 1:

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

Select from list by label example 2:

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

Anyone experienced this before where an item gets "selected" but the value does not get changed?


回答1:


Use following keyword.

Pass locator as 1st argument and value as another argument

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}


来源:https://stackoverflow.com/questions/42078974/select-from-list-selects-item-but-does-not-commit-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!