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

后端 未结 1 493
忘了有多久
忘了有多久 2021-01-24 06:58

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 initia

1条回答
  •  鱼传尺愫
    2021-01-24 07:52

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

    0 讨论(0)
提交回复
热议问题