簡體   English   中英

從codedUI中的單選按鈕獲取價值

[英]Get value from radio button in codedUI

我正在嘗試從網頁上的單選按鈕獲取變化值,以進行codedUI測試。 問題是,當我使用測試生成器記錄測試時,每次此單選按鈕value更改並且我的測試的單選按鈕都有固定值。 這是單選按鈕的html代碼

<input aria-label="Check Domain Factvlog 2:53:47 PM" type="radio" name="id[]" value="10">

我嘗試使用搜索配置,並將其設置為Always search屬性UIIDRadioButton

我還添加了這段代碼,試圖從頁面的htmlRadioButton元素中獲取值,但我不確定其正確性或技巧(我不是編碼器)。

HtmlRadioButton radioButton = new HtmlRadioButton();

radioButton.SearchProperties.Add(HtmlRadioButton.PropertyNames.Value, "value");
                radioButton.SearchProperties.Add(HtmlRadioButton.PropertyNames.Name, "id[]");
                radioButton.SearchProperties.Add(SearchConfiguration.AlwaysSearch);


        HtmlRadioButton uIIDRadioButton = this.UIDashboardCommonLookCWindow.UICreateNewTaskCommonLDocument.UIIDRadioButton;

運行測試消息時,總是出現此錯誤:System.ArgumentException:PropertyExpressionCollection.Add方法只能采用名稱/值對。 參數名稱:nameValuePairs

有任何想法嗎 ?

我認為您做錯了方法。

“ System.ArgumentException:PropertyExpressionCollection.Add方法只能在名稱-值對中使用。參數名稱:nameValuePairs”

這意味着您必須為您的searchconfiguration行分配一個值。

嘗試這個

radioButton.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM