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

故事扮演 提交于 2019-12-02 07:23:36

问题


i am testing a form of post a feed. where user can notify some existing user. while i am enter any data or character in the field its id is changes.

eg. if at the initial stage verifyValue id=token-input-auto_complete enter a data in the field ani verifyValue id=token-input-auto_complete ani

after enter the data in the field it shows only the character in the field but not shows any dropdown options


回答1:


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);


来源:https://stackoverflow.com/questions/11095234/how-to-select-an-option-from-an-autocomplete-field-in-selenium-ide

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!