在尝试单击元素时,如下所示:
element.all(by.repeater("condition in filterCtrl.conditions")).get(1).click();
我得到的错误是:
Failed: Element is not currently visible and so may not be interacted with".
我怎么能克服这一切。
我的CSS如下
<div class="_md-select-menu-container _md-active _md-clickable" aria-hidden="false" id="select_container_198" style="display: block; left: 764px; top: 181px; min-width: 234.547px;"><md-select-menu class="ng-scope _md-overflow" style="transform-origin: 101.273px 72px 0px;"><md-content>
<!-- ngRepeat: condition in filterCtrl.conditions --><md-option ng-repeat="condition in filterCtrl.conditions" value="CONTAINS" tabindex="0" class="ng-scope md-ink-ripple" aria-selected="false" role="option" id="select_option_257"><div class="_md-text ng-binding">Contains</div></md-option><!-- end ngRepeat: condition in filterCtrl.conditions -->option ng-repeat="condition in filterCtrl.conditions" value="ENDS_WITH" tabindex="0" class="ng-scope md-ink-ripple" role="option" aria-selected="false" id="select_option_261"><div class="_md-text ng-binding">Ends with</div></md-option><!-- end ngRepeat: condition in filterCtrl.conditions -->
</md-content></md-select-menu></div>"
发布于 2016-05-10 23:08:34
这是因为在单击元素之前打开了弹出窗口。通过单击URL来处理这个问题,这样弹出窗口就会关闭,并且量角器可以与元素交互。
发布于 2016-04-25 02:35:45
错误告诉您,元素当前不可见,所以它不能执行单击操作。不确定你的应用程序是如何设置的,如果它是棱角的,等等。但我建议尝试2件事:
1)如果该元素确实已加载,请尝试将其滚动到视图中。
var scrollIntoView = function () {
arguments[0].scrollIntoView();
}
browser.executeScript(scrollIntoView, yourwebelement);
或
2)确保该元素实际存在并显示在页面上。如果您将代码更改为expect
语句并添加.isPresent()
或.isDisplayed()
--这是否返回true?根据您的错误,我猜想isPresent()
返回true,而isDisplayed()
返回false。如果是这样的话,尝试添加一个隐式等待函数,在尝试单击元素之前等待元素加载。
https://stackoverflow.com/questions/36832873
复制相似问题