量角器中的元素不可单击

编程入门 行业动态 更新时间:2024-10-28 12:25:04
本文介绍了量角器中的元素不可单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

与模式弹出窗口中的任何元素交互时,我遇到问题.我正在使用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

更多推荐

量角器中的元素不可单击

本文发布于:2023-11-22 23:08:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619282.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:量角器   单击   元素

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!