Ejemplo n.º 1
0
        public void WhenTheUserSelectsTheOptionFromTheDropdown(NgWebDriver driver, By element, string partialText)
        {
            const int TIMEOUT = 2;

            driver.WaitForListToBePopulated(element, TIMEOUT);
            var hearingTypeOptions = new SelectElement(driver.WaitUntilElementExists(element));
            var found = false;

            if (hearingTypeOptions.Options.Any(option => option.Text.ToLower().Contains(partialText.ToLower())))
            {
                found = true;
                hearingTypeOptions.SelectByText(partialText);
            }

            var options = "";

            if (hearingTypeOptions.Options.Count < 10)
            {
                options = string.Join(",", hearingTypeOptions.Options.Select(i => i.Text).ToArray());
            }

            found.Should().BeTrue($"Option '{partialText}' found in the list of options {options}");
            driver.WaitUntilElementExists(element, TIMEOUT).SendKeys(Keys.Tab);
        }