Can selenium handle autocomplete?

前端 未结 17 1284
粉色の甜心
粉色の甜心 2020-12-09 04:26

I have a test case that requires typing in a partial value into an ajax based textfield and verifying the list has the expected content. If it does, select the content. An

17条回答
  •  独厮守ぢ
    2020-12-09 05:14

    Your question is slightly ambigious.

    Most browsers keep a value cache that is based on the name of the field: This is the value that is being suggested as autocompletion by your browser even though you may never have visited the site before. This feature is non-standard across all browsers, and there's going to be no standard way for selenium to detect/analyze this. You can still do it, but you'll have to make javascript functions that determine the values yourself. Then you can use "eval" in selenium to execute these functions. I have not seen any js libraries that can tell you these values in a cross-browser compatible way.

    The other alternative is that you use ajax to do a server-side submit of the partially entered value. In this case it's just a matter of typing the values into the textbox and asserting that the expected values turn up. Normally the autocomplete suggestions show up in some layer on the client side.

提交回复
热议问题