使用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 label
和select 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
在项目被“选中”但价值没有改变之前,任何人都经历过这种情况吗?
答案 0 :(得分:2)
使用以下关键字。
将定位器作为第一个参数传递,将值作为另一个参数传递
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}