指定されたリストからオプションを選択するための次のコードがあり、通常は機能しますが、2番目のifでNoSuchElement例外が発生して失敗することがあります。要素が見つからない場合は、ループに戻るだけだという印象を受けました。説明はとても簡単だと思います...誰かが私を教えてくれませんか?
public static void selectFromList(String vList, String vText, IWebDriver driver)
{
for (int sec = 0; ; sec++)
{
System.Threading.Thread.Sleep(2500);
if (sec >= 10) Debug.Fail("timeout : " + vList);
if (driver.FindElement(By.Id(ConfigurationManager.AppSettings[vList])).Displayed) break;
}
new SelectElement(driver.FindElement(By.Id(ConfigurationManager.AppSettings[vList]))).SelectByText(vText);
}