Chọn một chuổi trong listbox

Chọn một item từ một listbox với Selenium, WebDriver

//Select an item string of a listbox
bool SelectItem(string id, string item){
  bool ret = false;
  IWebElement listbox = driver.FindElement(By.Id(id));
  ReadOnlyCollection<IWebElement> options = myEle.FindElements(By.TagName("option"));
    foreach(IWebElement option in options){
        if (option.Text.Equals(item, StringComparison.OrdinalIgnoreCase))
        {
          option.Click();
          break; 
        }
    }
  return ret;
}

Không có nhận xét nào:

Đăng nhận xét