在 Selenium RC 的 head 标签内运行 javascript

发布于 2024-09-03 07:20:56 字数 157 浏览 3 评论 0原文

我想在 标记内运行 JavaScript 代码片段。在 Selenium RC+Java 中可以做到这一点吗?

我知道如果我使用 getEval 或 runScript 会将代码插入 HTML 正文中。

有什么想法吗?

谢谢

I want to run a javascript snippet inside the <head> tag. Is that possible to do that in Selenium RC+Java?

I understood that if I use getEval or runScript that will insert the code inside the HTML body.

Any Ideas?

Thanks

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

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

发布评论

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

评论(1

蹲墙角沉默 2024-09-10 07:20:56

我的理解是,当 Selenium 能够与页面交互时,它已经被加载,这意味着您将无法向 添加内容。元素。

您可以使用 runScript 使用 DOM 操作技术动态地将脚本标记添加到 head 元素,但这可能也不是您想要的......

My understanding is that by the time Selenium is able to interact with the page, it has already been loaded, which means you wouldn't be able to add something to the <head> element.

You could use runScript to dynamically add a script tag to the head element using DOM manipulation techniques but this is probably not what you're after either...

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