如何使用selenium RC测量网页中元素的位置?

发布于 2024-12-03 00:24:55 字数 88 浏览 5 评论 0原文

我已经尝试了很多方法来找出如何在不同的浏览器中测量网页中元素的坐标。但我找不到任何解决方案。

有没有其他工具可以测量元素在各种浏览器中的位置???

I have tried a lot in finding out how measure the coordinate of an element in a web page in different browser.But I could not find any solution.

Is there any other tool that can measure the position of an element in various browsers???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

累赘 2024-12-10 00:24:55

在 AutoIt 中,您可以使用以下代码来获取屏幕坐标(在我的示例中,用于在 Internet Explorer 上将工具提示显示为覆盖层):

$oIE = _IECreate("http://...URL...")
$username = _IEFormElementGetObjByName(_IEFormGetObjByName($oIE, "loginform"), "username")
ToolTip("Login", _IEPropertyGet($username, "screenx"), _IEPropertyGet($username, "screeny"))
_IEAction($username, "focus")

或者您可以使用 _IEGetObjById($oIE, "mx77")获取对象引用。或者按标签名称遍历所有元素,如此处所示。
您可以使用以下方法获取浏览器内位置,而不是获取绝对屏幕位置
browserxbrowsery

In AutoIt you can use the following code to get screen coordinates (in my example for displaying a tool tip as an overlay on an Internet Explorer):

$oIE = _IECreate("http://...URL...")
$username = _IEFormElementGetObjByName(_IEFormGetObjByName($oIE, "loginform"), "username")
ToolTip("Login", _IEPropertyGet($username, "screenx"), _IEPropertyGet($username, "screeny"))
_IEAction($username, "focus")

Alternatively you can use _IEGetObjById($oIE, "mx77") to get an object reference. Or run through all all elemnts by tag name as shown here.
Instead of getting the absolute screen position, you can get the In-Browser-Position, using
browserx and browsery.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文