与模式弹出窗口中的任何元素交互时,我遇到问题.我正在使用ChromeDriver 2.46,并且所有涉及模式弹出窗口的测试在Chrome 74上均失败.
I am facing issue while interacting with any element in a modal popup. I am using ChromeDriver 2.46 and all tests which involves modal popup fails on Chrome 74.
我遇到错误
元素不可点击.其他元素将获得点击
我尝试使用 scrollToTop , scrollToElement 和 visibilityOf ,但是没有任何效果.有人遇到过类似的问题吗?
I have tried with scrollToTop, scrollToElement and visibilityOf but nothing worked. Has anyone faced similar issue?
推荐答案为您附加html和完整的错误堆栈
Attach you html, and full error stack
同时这是我的假设,您的问题很可能是90%
Meanwhile here is my assumption which is 90% likely what your problem is
让我们假设您的html类似于
Lets assume your html is something like
<div> <button></button> </div>您的按钮可见...但是 div 元素也可见.但是因为包装按钮,所以它在按钮上方(z索引较高).这就是为什么当您单击按钮时,div会获得此单击,而量角器不会发生这种情况.失败了
your button is visible... but so is div element. BUT because wraps the button, it is above the button (has higher z-index). That's why when you click button, div gets this click, which protractor doesn't let happen. And fails
在这种情况下,只需使用js click
In this case just simply use js click
browser.executeScript( "arguments[0].click();", $element.getWebElement() // substitute $element to your elementFinder )这将起作用,因为无论可见度和页面布局如何,元素都会获得点击
this will work because element gets the click regardless of visibility and the page layout
更多推荐
量角器中的元素不可单击
发布评论