private void SelectSearchResults(int number) { IWebDriver browser = TestRunnerInterface.Map.safePage.browser; Libary.WaitForElementByXpath(browser, "//input[@type='button' and @value='Add']", RunTimeVars.PAGELOADWAIT); ReadOnlyCollection <IWebElement> addButtons = browser.FindElements(By.XPath("//input[@type='button' and @value='Add']")); var count = addButtons.Count; if (count == 1) { addButtons[0].Click(); } else { addButtons[--number].Click(); } }