如何从使用 selenium webdriver 中的 api 响应动态启动的下拉列表中选择特定位置?

2024-02-20

问题描述:

我正在尝试自动填写表格,其中有 地点下拉列表。我在选择选项时遇到问题 这些是建议列表中建议的。中的选项 建议列表由 API 响应(即其动态)提供。 我无法从建议列表中选择选项之一。

String Locality ="//label[contains(text(),'Locality')]/following-sibling::input";

public void insertData(DataTable str) throws InterruptedException {
    List<List<String>> list = str.asLists(String.class);
    super.identifyElement(locators.xpath, Locality), list.get(1).get(5));// value sendkey= Akurdi;

HTML 元素:

<label _ngcontent-c4="" for="Location" class="active">Locality</label>
<input _ngcontent-c4="" autocapitalize="off" autocorrect="off" class="mb-0 ng-valid ng-dirty ng-touched" formcontrolname="locality" placeholder="" spellcheck="off" stype="locality" type="text" ng-reflect-klass="mb-0" ng-reflect-ng-class="[object Object]" ng-reflect-name="locality" ng-reflect-model="Akurdi" autocomplete="off">

从黄瓜场景发送键值: 阿库尔迪...显示输入下拉列表 UI https://i.stack.imgur.com/KuMwf.png


在这些情况下,我将像通常的列表一样使用这些下拉菜单。单击下拉菜单打开,等待下拉菜单出现,然后在其元素列表中迭代,按名称搜索我需要的内容,然后单击它。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何从使用 selenium webdriver 中的 api 响应动态启动的下拉列表中选择特定位置? 的相关文章

随机推荐