选择从列表选择项目,但不提交更改 [英] Select From List selects item but does not commit change

查看:113
本文介绍了选择从列表选择项目,但不提交更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用机器人框架,我有一个下拉列表与多个选项。当我使用从列表中选择选项时,我可以看到选择被突出显示,但是当下拉列表关闭时,该值不会更改。

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.

以下是我的代码示例:

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

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

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

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

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?

推荐答案

使用以下关键字。

通过定位器作为第一个参数和值作为另一个参数

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}

这篇关于选择从列表选择项目,但不提交更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆