我无法选择标签列表中的项目,
我尝试对列表中的每个元素都使用
我如何搜索显示的索引和选项:
foreach (var a in nameoflist)
{
Console.WriteLine("ddm" + a.Text);
}
我如何选择列表中的项目:
List<IWebElement> dropDownMenu = driver.FindElements(By.ClassName("dropdown-menu"));
IList<IWebElement> selectdomain = dropDownMenu[0].FindElements(By.TagName("li"));
selectdomain[0].Click();
外部HTML:
<ul class="dropdown-menu ng-isolate-scope" ng-class="{'closed-typeahed' : !isOpen()}" ng-style="{top: position().top+'px', left: position().left+'px'}" role="listbox" aria-hidden="false" uib-typeahead-popup="" id="typeahead-1511-7724" matches="matches" active="activeIdx" select="select(activeIdx, evt)" move-in-progress="moveInProgress" query="query" position="position" assign-is-open="assignIsOpen(isOpen)" debounce="debounceUpdate" popup-template-url="typeahead-custom-popup.html" style="top: 34px; left: 0px;">
<!-- ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-0">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="csv.user03@coreviewlab.com">csv.<strong>user</strong>03@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-1">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="csv.user@coreviewlab.com">csv.<strong>user</strong>@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-2">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="synch.user7@coreviewlab.com">synch.<strong>user</strong>7@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope active" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-3">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="hybrid.usermodified@coreviewlab.com">hybrid.<strong>user</strong>modified@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-4">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="csv.user02@coreviewlab.com">csv.<strong>user</strong>02@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-5">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="csve.user04@coreviewlab.com">csve.<strong>user</strong>04@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-6">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="csve.user05@coreviewlab.com">csve.<strong>user</strong>05@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-7">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="testuser.01@coreviewlab.com">test<strong>user</strong>.01@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-8">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="carmine.syncuser@coreviewlab.com">carmine.sync<strong>user</strong>@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index --><li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-9">
<a href="" tabindex="-1" ng-bind-html="match.label | uibTypeaheadHighlight:query" ng-attr-title="{{match.label}}" class="ng-binding ng-scope" title="newhybrid.user@coreviewlab.com">newhybrid.<strong>user</strong>@coreviewlab.com</a>
</li><!-- end ngRepeat: match in matches track by $index -->
<li><div class="typeahead-no-results small ng-hide" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label == '')"><span translate="" class="ng-scope">No result found</span></div></li>
</ul>
li的HTML
<li class="uib-typeahead-match ng-scope" ng-show="isOpen() && !moveInProgress && (matches[0] && matches[0].label != '')" 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-1511-7724-option-0">
我总是收到“索引超出范围”错误。并且,我必须手动搜索有效的索引。我该如何自动选择任何选项?
答案 0 :(得分:1)
尝试将计数验证放在首位
IList<IWebElement> selectdomain = dropDownMenu[0].FindElements(By.TagName("li"));
var count = selectdomain.Count();
if (count > 0){
selectdomain[0].Click();
}
答案 1 :(得分:0)
我从未使用过硒,但是您可以尝试以下方法:
curl_setopt($ch, CURLOPT_ENCODING, '');