driver.Navigate().GoToUrl("http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx");
driver.FindElement(By.XPath("//input[contains(@id,'SampleContent_myTextBox')]")).SendKeys("test");
Thread.Sleep(TimeSpan.FromSeconds(2));
IWebElement element = driver.FindElement(By.XPath("//div[contains(@id,'master_contentplaceholder')]//div//ul"));
ReadOnlyCollection<IWebElement> texts=element.FindElements(By.TagName("li"));
IKeyboard key = ((IHasInputDevices)driver).Keyboard;
foreach(IWebElement text in texts)
{
key.PressKey(Keys.ArrowDown);
if (Equals("testMal", text.Text))
{
Console.WriteLine(text.Text);
key.PressKey(Keys.Enter);
}
else
{
key.PressKey(Keys.ArrowDown);
key.PressKey(Keys.Enter);
}
}
driver.FindElement(By.XPath("//input[contains(@id,'SampleContent_myTextBox')]")).SendKeys("test");
Thread.Sleep(TimeSpan.FromSeconds(2));
IWebElement element = driver.FindElement(By.XPath("//div[contains(@id,'master_contentplaceholder')]//div//ul"));
ReadOnlyCollection<IWebElement> texts=element.FindElements(By.TagName("li"));
IKeyboard key = ((IHasInputDevices)driver).Keyboard;
foreach(IWebElement text in texts)
{
key.PressKey(Keys.ArrowDown);
if (Equals("testMal", text.Text))
{
Console.WriteLine(text.Text);
key.PressKey(Keys.Enter);
}
else
{
key.PressKey(Keys.ArrowDown);
key.PressKey(Keys.Enter);
}
}
This comment has been removed by the author.
ReplyDelete