how to select an option from an autocomplete field in selenium ide

北城以北 提交于 2019-12-02 03:00:54

Do you mean a jQuery autocomplete? Or some other type of autocomplete (please name it if so)

This is how I select a jQuery autocomplete list value in selenium: (note this is typed in code, not recorded code). It is a bit tricky, you have to make it trigger the autocomplete, then you have to highlight the value, then you have to select it.

string locator = "id=token-input-auto_complete";
string value = "CATS";
selenium.Focus(locator);
selenium.Type(locator, value);
selenium.KeyDown(locator, "\\40");
Thread.Sleep(50);
selenium.KeyDown(locator, "\\40");
Thread.Sleep(50);
selenium.KeyDown(locator, "\\13");
Thread.Sleep(50);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!