如何在webdriver中处理自动完成列表? [英] How to handle autocomplete list in webdriver?

查看:104
本文介绍了如何在webdriver中处理自动完成列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从自动完成下拉列表中选择国家/地区名称?

How to select country name from auto-complete drop down list?

请提供有关Google搜索代码的建议,以便我理解.

Please provide suggestion with code for Google search so that i can understand.

推荐答案

如果下拉列表是可编辑的,则可以使用发送键直接键入值,否则您需要根据需要模拟Arrow down键的操作.但这不是一次明智的选择,因为如果在下拉列表中添加新值(无论如何,由于国家/地区的数目为常数,该值将是固定的),那么它将变得一团糟.

If your dropdown is editable you can directly type the values using send keys, else you need to simulate the Arrow down key actions as you needed. But it not wise once, because if new values are added in the drop down(Anyway in this case, there will be fixed because the number of countries is a constant),then it will get messed.

driver.findElement(locator).sendKeys(countryName , Keys.TAB);

driver.findElement(locator).sendKeys(Keys.DOWN);

这篇关于如何在webdriver中处理自动完成列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆