英文:
I am not able to select an element from dynamic search box using selenium with java
问题
动态搜索列表位于一个 ul 标签下,其中包含不同的 li 标签。在 li 标签下,有两个子元素,其中 span 标签包含了值。
<ul class="dropdown-menu ng-isolate-scope" ng-show="isOpen() &amp;&amp; !moveInProgress" ng-style="{top: position().top+'px', left: position().left+'px'}" role="listbox" aria-hidden="false" uib-typeahead-popup="" id="typeahead-60-892" matches="matches" active="activeIdx" select="select(activeIdx, evt)" move-in-progress="moveInProgress" query="query" position="position" assign-is-open="assignIsOpen(isOpen)" debounce="debounceUpdate" template-url="postlogin/admin/clientProvision/typeAheadResultsTemplate.html" style="top: 34px; left: 10px;">
<!-- ngRepeat: match in matches track by $index -->
<li class="uib-typeahead-match ng-scope active" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index, $event)" role="option" id="typeahead-60-892-option-0" tabindex="0" style="">
<a class="law-firm-office-name-search-result ng-scope">
<span ng-bind-html="match.label | uibTypeaheadHighlight:query" class="ng-binding"><strong>**Baker Tilly Beers &amp;</strong> Cutler, PLLC, Tysons Corner</span>
</a>
</li><!-- end ngRepeat: match in matches track by $index -->
<li class="uib-typeahead-match ng-scope" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index, $event)" role="option" id="typeahead-60-892-option-1" tabindex="0">
<a class="law-firm-office-name-search-result ng-scope">
<span ng-bind-html="match.label | uibTypeaheadHighlight:query" class="ng-binding"><strong>**Baker Tilly Beers &amp;</strong> Cutler, PLLC, Vienna VA</span>
</a>
</li><!-- end ngRepeat: match in matches track by $index -->
</ul>
我了解你的方法,但我无法创建能够获取 Web 元素列表的 XPath,然后我可以将其与我想要发送的文本进行比较。
英文:
Dynamic search list is under one ul tag and it has different li tags . Under li tags, it has two childs in which span tag contains the value.
<ul class="dropdown-menu ng-isolate-scope" ng-show="isOpen() &amp;&amp; !moveInProgress" ng-style="{top: position().top+'px', left: position().left+'px'}" role="listbox" aria-hidden="false" uib-typeahead-popup="" id="typeahead-60-892" matches="matches" active="activeIdx" select="select(activeIdx, evt)" move-in-progress="moveInProgress" query="query" position="position" assign-is-open="assignIsOpen(isOpen)" debounce="debounceUpdate" template-url="postlogin/admin/clientProvision/typeAheadResultsTemplate.html" style="top: 34px; left: 10px;">
<!-- ngRepeat: match in matches track by $index -->
<li class="uib-typeahead-match ng-scope active" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index, $event)" role="option" id="typeahead-60-892-option-0" tabindex="0" style="">
<a class="law-firm-office-name-search-result ng-scope">
<span ng-bind-html="match.label | uibTypeaheadHighlight:query" class="ng-binding"><strong>**Baker Tilly Beers &amp;</strong> Cutler, PLLC, Tysons Corner**</span>
</a>
</li><!-- end ngRepeat: match in ma``tches track by $index --><li class="uib-typeahead-match ng-scope" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index, $event)" role="option" id="typeahead-60-892-option-1" tabindex="0">
<a class="law-firm-office-name-search-result ng-scope">
<span ng-bind-html="match.label | uibTypeaheadHighlight:query" class="ng-binding"><strong>**Baker Tilly Beers &amp;</strong> Cutler, PLLC, Vienna VA**</span>
</a>
</li><!-- end ngRepeat: match in matches track by $index -->
</ul>
I know the approach but I am not able to create the xpath so that I can get a list of Web Elements and then I can compare with the text I want to send
专注分享java语言的经验与见解,让所有开发者获益!
评论