Here is code I'm using to scroll through a list of districts:
IWebElement districtsList = modelAddInvoice.ReturnDistrictInvoiceAddDistrict();
districtsList.Click();
districtsList.SendKeys(Keys.ArrowDown);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowDown);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowDown);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowDown);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowDown);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowUp);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowUp);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowUp);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowUp);
Thread.Sleep(1000);
districtsList.SendKeys(Keys.ArrowUp);
This will do what's expected. I scroll to the 5th item, then back to the first.
If I try this, nothing happens:
IWebElement districtsList = modelAddInvoice.ReturnDistrictInvoiceAddDistrict();
Actions selectDistrict = new(_browserFixture.EdgeDriver);
selectDistrict.MoveToElement(districtsList).Click();
// or
selectDistrict.MoveToElement(districtsList).Perform();
End users will be using their mouse. So, using space bar or click to expose the list and then scrolling with Send Keys, that's not real-world. Nothing happens at all when using Actions.
If I'm not using Kendo items, the Actions class methods do work.
Googling for this specific use case hasn't exposed yet this same scenario.
Could not copy the HTML but here is a screen shot showing District 5 selected.
So, there's a bit of CSS magic happening, this is not the usual Drop- Down List.
Making a mouse hover, mouse click, scroll, etc. just may not work for this use case.
Thanks for helping.
-
You need to edit your question and add the portion of the HTML containing the label and dropdown, "District: * [ 5 v ]". You should be able to at least copy/paste that portion of the page. You also need to add the locator(s) you are using to the question. Right now you're calling a method that you haven't provided the code for.JeffC– JeffC2025年12月11日 05:54:36 +00:00Commented Dec 11, 2025 at 5:54
1 Answer 1
Since we don't have the HTML of your page, I found a sample Kendo UI dropdown demo page and wrote a script against it. I had to create a custom method to set the dropdown value because the first click never registers correctly. The first click opens and then immediately closes the dropdown... so I have to click again and wait until the desired element is visible.
The main script
IWebDriver driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "https://demos.telerik.com/kendo-ui/dropdownlist/index";
SetCity(driver, "Berlin");
driver.Quit();
The SetCity() method
public void SetCity(IWebDriver driver, string city)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
IWebElement dropdown = wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("span.k-input-value-text")));
dropdown.Click();
while (true)
{
try
{
wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[text()='Berlin']"))).Click();
break;
}
catch (Exception e) when (e is WebDriverTimeoutException || e is ElementNotInteractableException)
{
dropdown.Click();
}
}
}