gpt4 book ai didi

iframe - 访问 Selenium 中动态生成的 iframe 的内容

转载 作者:行者123 更新时间:2023-12-02 17:28:52 26 4
gpt4 key购买 nike

我想使用 XPath(或其他 Selenium DSL 定位器)来访问动态创建的 iframe。我的目标是对该动态 iframe 的内容做出一些断言。

iframe 没有 ID,仅具有以下 HTML 属性:

src="javascript:""" style="position: absolute; left: -2000px;"

如果我能以某种方式 selectFrame iframe,那么我就可以 assertText 或使用 XPath 来测试 iframe 内部结构。

然而,简单的方法似乎失败了。 selectFrame("index=0") 由于某种原因失败。也许我需要某种方法来waitFor加载iframe。但我似乎无法为 iframe 创建定位器标识符,因此我无法 waitFor 它。

最佳答案

您尝试过 Selenium 文档中的这些技巧吗?

SelectFrame ( locator ) Selects a frame within the current window. (You may invoke this command multiple times to select nested frames.) To select the parent frame, use "relative=parent" as a locator; to select the top frame, use "relative=top". You may also use a DOM expression to identify the frame you want directly, like this: dom=frames["main"].frames["subframe"]

http://release.seleniumhq.org/selenium-core/0.8.0/reference.html

关于iframe - 访问 Selenium 中动态生成的 iframe 的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4321921/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com