量角器中的元素不可点击 [英] Element is not clickable in Protractor
问题描述
我在与模式弹出窗口中的任何元素交互时遇到问题.我正在使用 ChromeDriver 2.46,所有涉及模式弹出的测试在 Chrome 74 上都失败了.
我得到以下错误
元素不可点击.其他元素会收到点击
我尝试过使用 scrollToTop
、scrollToElement
和 visibilityOf
,但没有任何效果.有没有人遇到过类似的问题?
附上你的html,以及完整的错误堆栈
同时,这是我的假设,90% 可能是您的问题
假设您的 html 类似于
<按钮></按钮></div>你的按钮是可见的......但是 div
元素也是如此.但是因为包裹了按钮,所以它在按钮上方(具有更高的 z-index).这就是为什么当你点击按钮时,div 会得到这个点击,而量角器不会让这种情况发生.失败了
在这种情况下,只需简单地使用 js 点击
browser.executeScript("参数[0].click();",$element.getWebElement()//将 $element 替换为您的 elementFinder)
这会起作用,因为无论可见性和页面布局如何,元素都会获得点击
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.
I get below error
element is not clickable. Other element would receive the click
I have tried with scrollToTop
, scrollToElement
and visibilityOf
but nothing worked. Has anyone faced similar issue?
解决方案 Attach you html, and full error stack
Meanwhile here is my assumption which is 90% likely what your problem is
Lets assume your html is something like
<div>
<button></button>
</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
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
这篇关于量角器中的元素不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文