单击使用div标签开发的下拉列表时,我收到Element not clickable错误。
这里是HTML代码:
<div class="form-control btn-group ui-multiselect-dropdown ng-isolate-scope ng-valid ng-valid-schema-form ng-touched" data-role="multiselect" ng-init="open=false" ng-class="{open: open}" autopopulate-to="form" populate-to="form" reload-options="form" schema-name="form" sf-changed="form" schema-validate="form" auto-tab-field="" ng-model="model['notifications']['preferredMedium']" tabindex="15" ng-disabled="form.readonly || (form.enabled && !evalExpr(form.enabled,{ model: model, 'arrayIndex': arrayIndex }))" preselected="model['notifications']['preferredMedium']" options="form.titleMap" name="notifications.preferredMedium" style="">
<div class="ui-multiselect-dropdown-description ng-binding" ng-bind="selectedDescription || 'Select'">Select</div>
<ul class="dropdown-menu" autofocus="autofocus">
<li class="ui-multiselect-dropdown-option" data-value="select-all" data-role="option" ng-click="selectAll()">Check All</li>
<li class="ui-multiselect-dropdown-option" data-value="unselect-all" data-role="option" ng-click="deselectAll();">Uncheck All</li>
<li class="divider"/>
<li class="ui-multiselect-dropdown-option ng-binding ng-scope" ng-attr-data-checked="{{isChecked(option.value) ? 1 : 0}}" data-type="value" ng-attr-data-value="{{::option.value}}" data-role="option" ng-class="{selected: keyBoardPointer(option.value)}" ng-click="setSelectedItem(option)" ng-repeat="option in options" data-checked="0" data-value="email"> Email </li>
<li class="ui-multiselect-dropdown-option ng-binding ng-scope" ng-attr-data-checked="{{isChecked(option.value) ? 1 : 0}}" data-type="value" ng-attr-data-value="{{::option.value}}" data-role="option" ng-class="{selected: keyBoardPointer(option.value)}" ng-click="setSelectedItem(option)" ng-repeat="option in options" data-checked="0" data-value="mobileNo"> SMS </li>
<li class="ui-multiselect-dropdown-option ng-binding ng-scope" ng-attr-data-checked="{{isChecked(option.value) ? 1 : 0}}" data-type="value" ng-attr-data-value="{{::option.value}}" data-role="option" ng-class="{selected: keyBoardPointer(option.value)}" ng-click="setSelectedItem(option)" ng-repeat="option in options" data-checked="0" data-value="phoneNo"> Phone </li>
<li class="ui-multiselect-dropdown-option ng-binding ng-scope" ng-attr-data-checked="{{isChecked(option.value) ? 1 : 0}}" data-type="value" ng-attr-data-value="{{::option.value}}" data-role="option" ng-class="{selected: keyBoardPointer(option.value)}" ng-click="setSelectedItem(option)" ng-repeat="option in options" data-checked="0" data-value="fax"> Fax </li>
</ul>
我创建了如下元素:
@FindBy(css="div[name='notifications.preferredMedium']")
private WebElement profPrefMedium;
出现的错误如下:“元素在点上无法点击(1172.199951171875,642.2999877929688)。 其他元素将收到点击:“。
任何人都可以提供帮助。
答案 0 :(得分:0)
您可以尝试使用Expeceted条件的显式等待
WebDriverWait myWait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement buttonToClick = myWait.Until(ExpectedConditions.ElementToBeClickable(By.Id("yourelementid")));
if (buttonToClick != null) buttonToClick.Click();
答案 1 :(得分:0)
Finally, I got answer.
It worked with javascriptExecutor.
`jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].click();",profPrefMedium);`
Thanks all for your help in solving my problem.
答案 2 :(得分:-1)
请尝试MovetoElement(Actions)
,然后执行click()
也许这会帮助您解决问题
根据指南,代码应按上述格式进行格式化。