public void ShouldSelectOneByOne() { // Given multuselect directive NgWebElement ng_directive = ngDriver.FindElement(NgBy.Model("selectedCar")); Assert.IsNotNull(ng_directive.WrappedElement); Assert.That(ng_directive.TagName, Is.EqualTo("am-multiselect")); // open am-multiselect IWebElement toggleSelect = ng_directive.FindElement(By.CssSelector("button[ng-click='toggleSelect()']")); Assert.IsNotNull(toggleSelect); Assert.IsTrue(toggleSelect.Displayed); toggleSelect.Click(); // When I want to select every "Audi", "Honda" or "Toyota" car String makeMatcher = "(?i:" + String.Join("|", new String[] { "audi", "honda", "toyota" }) + ")"; ReadOnlyCollection <NgWebElement> cars = ng_directive.FindElements(NgBy.Repeater("i in items")); Assert.Greater(cars.Count(car => Regex.IsMatch(car.Text, makeMatcher)), 0); // And I pick every matching car one item at a time int selected_cars_count = 0; for (int num_row = 0; num_row < cars.Count(); num_row++) { NgWebElement ng_item = ng_directive.FindElement(NgBy.Repeaterelement("i in items", num_row, "i.label")); if (Regex.IsMatch(ng_item.Text, makeMatcher, RegexOptions.IgnoreCase)) { Console.Error.WriteLine("Selecting: " + ng_item.Text); ng_item.Click(); selected_cars_count++; ngDriver.Highlight(ng_item, highlight_timeout); } } // Then button text shows the total number of cars I have selected IWebElement button = driver.FindElement(By.CssSelector("am-multiselect > div > button")); ngDriver.Highlight(button, highlight_timeout); StringAssert.IsMatch(@"There are (\d+) car\(s\) selected", button.Text); int displayed_count = 0; int.TryParse(button.Text.FindMatch(@"(?<count>\d+)"), out displayed_count); Assert.AreEqual(displayed_count, selected_cars_count); Console.Error.WriteLine("Button text: " + button.Text); try { // NOTE: the following does not work: // ms-selected = "There are {{selectedCar.length}} NgWebElement ng_button = new NgWebElement(ngDriver, button); Console.Error.WriteLine(ng_button.GetAttribute("innerHTML")); NgWebElement ng_length = ng_button.FindElement(NgBy.Binding("selectedCar.length")); ng_length = ngDriver.FindElement(NgBy.Binding("selectedCar.length")); Console.Error.WriteLine(ng_length.Text); } catch (NullReferenceException) { } }