Что-то вроде:
char c1 = (index < c.Length - 1) ? c[index].nextItem() : c[0];
Если вы хотите использовать метод, вы можете просто вернуть индекс:
char c1 = c[CheckIndex(index, c.Length())];
public static int CheckIndex(int index, int length)
{
return index < length - 1 ? index : 0;
}
Кажется, есть дополнительный символ '
в атрибуте Id , который вы использовали. Кроме того, кажется, что элемент является динамическим, поэтому вам нужно вызвать WebDriverWait , и вы можете использовать любое из следующих решений:
Id
:
new WebDriverWait(foxdriver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.Id("btnStopSs"))).Click();
CssSelector
:
new WebDriverWait(foxdriver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("input#btnStopSs[value='Stop']"))).Click();
XPath
:
new WebDriverWait(foxdriver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id='btnStopSs' and @value='Stop']"))).Click();