如何使用 Watir Webdriver 确定元素的坐标?

编程入门 行业动态 更新时间:2024-10-07 18:28:58
本文介绍了如何使用 Watir Webdriver 确定元素的坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有问题.在解析页面时,会出现一个弹出窗口并阻止对 html 的访问.我试图点击弹出窗口,但它会将我重定向到一个新页面,我不知道如何到达弹出窗口的右上角区域来关闭它.我的问题是如何确定该元素的坐标?Stackoverflow 上提出的相关问题都没有帮助我找到解决方案,因此非常感谢您的帮助.

I have a problem. While parsing a page, a pop-up window appears and blocks access to html. I tried to click on the pop-up, but it re-directs me to a new page, and I have no clue how to get to the upper right area of the pop-up to close it. My question is how to determine the coordinates of that element? None of the related issues raised here at Stackoverflow helped me find a solutions, so assistance would be very much appreciated.

推荐答案

为什么需要实际坐标?鉴于它可以在不同的屏幕尺寸(响应式设计)上移动或产生不同的结果,这似乎是一个坏主意.你最好找到关闭按钮的类/id 并调用 browser.button(class: 'close').clickbrowser.link(class: 'close').click.

Why do you need the actual coordinates? That seems like a bad idea given it could move or have different results on different screen sizes (responsive designs). You'd be better off finding the class / id of the close button and calling browser.button(class: 'close').click or browser.link(class: 'close').click.

如果您需要帮助确定关闭按钮的类别,请打开浏览器并启用开发人员工具/控制台.他们现在都有一个检查器工具来选择元素并找到所有类和;id.

If you need help determining the class of the close button, open your browser and enable developer tools / console. They all have an inspector tool now to select the element and find all classes & ids.

万一没有类或 id,它可能有一个 data 属性,您可以使用它.

In the unlikely event there are no classes or ids it may have a data attribute you could work off.

这篇关于如何使用 Watir Webdriver 确定元素的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 21:16:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1142746.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:坐标   如何使用   元素   Webdriver   Watir

发布评论

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

>www.elefans.com

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