【发布时间】:2014-01-24 19:25:51
【问题描述】:
我是 Selenium 的新手,能够从下拉列表中选择一个值,但似乎无法为单选按钮执行此操作。这是我用于下拉列表的代码:
public void SelectValueById(string element, string text) {
//Get hold of the dropdown box by Name
IWebElement dropDown = commondriver.FindElement(By.Id(element));
//Place the drop down into selectElement
SelectElement clickThisitem = new SelectElement(dropDown);
//Select the Item from dropdown by Text
clickThisitem.SelectByText(text);
}
这很好用。我想用单选按钮做同样的事情。我想传入相同的两个参数——单选按钮 id 或 xpath,以及要选择的选项的名称/值——并让函数单击正确的选项。
【问题讨论】:
标签: c# selenium selenium-webdriver