2017-02-06 110 views
0

使用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 

任何人都經歷

由值例子列表

選擇這之前,項目獲得「選擇」,但價值不會改變?

回答

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} 
+0

感謝阿卡什!我會嘗試一下! –

+0

如果仍然有任何問題,請告訴我 –

+0

我所做的唯一更改是我的系統無法將//字符識別爲評論指示符。我使用了#字符,它的運行非常漂亮。再次感謝! –