问题描述
问题描述:
我正在尝试自动填写有位置下拉列表.我在选择选项时遇到问题这是建议列表中的建议.中的选项建议列表由 api 响应提供,即它的动态.我无法从建议列表中选择其中一个选项.
I am trying to automate the filling of the form in which there's alocality dropdown list. I am facing problem in selecting the optionwhich are suggest in the suggestion list. The options in thesuggestions list are provided by an api response i.e its dynamic.I am not able to select one of the option from the suggested list.
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
Sendkey value form cucumber screnario:Akurdi...Display Input dropdown list UI
推荐答案
在这些情况下,我会像平常一样使用这些下拉列表.单击下拉打开,等待下拉出现,然后在它的元素列表中迭代,按名称搜索我需要的内容,然后单击它.
In these cases I am working with these drop-downs as with usual List. Clicking on drop-down opening, waiting for drop-down to appear, then iterating in the list of it's elements, searching what I need by name, then clicking on it.
这篇关于如何从使用 selenium webdriver 中的 api 响应动态启动的下拉列表中选择特定位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!