【发布时间】:2016-05-26 09:44:17
【问题描述】:
我的问题是我正在尝试处理的页面上有 3 个已定义的 iFrame。它们都被命名为:
<iframe class="col-51" height="560" src="https://attendee.gototraining.com/embed/886b2/catalog/40xxxx bgColor=ffffff" frameborder="0"></iframe>
<iframe class="col-51" height="560" src="https://attendee.gototraining.com/embed/886b2/catalog/37xxxx bgColor=ffffff" frameborder="0"></iframe>
<iframe class="col-51" height="560" src="https://attendee.gototraining.com/embed/886b2/catalog/46xxxx bgColor=ffffff" frameborder="0"></iframe>
我尝试了 driver.switchTo.frame 命令,但它只看到索引 0,我认为它是此处列出的第一帧。如果我选择这第一帧,我不会在运行时收到错误,但是我仍然看不到帧内的任何元素。我得到“找不到元素”的问题。我什至无法使用我制作的定位或索引 1 或 2 选择带有 switchTo 的第 2 帧或第 3 帧。
我也尝试过制作一个包含 iframe 的所有标记名的列表。我只得到 1 个结果。同样,我在这里看到 3。同样,即使我选择了第一个,我仍然无法使用常规方式看到框架内的任何元素。
我在这里错过了什么?
另外请注意,出于隐私考虑,我在路径中添加了 x。
如果我选择 0 以外的其他索引会发生什么情况:
org.openqa.selenium.NoSuchFrameException: Unable to locate frame: 1
Command duration or timeout: 62 milliseconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:03:33'
System info: host: 'DESKTOP-1PV0EPA', ip: '192.168.0.11', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=46.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
【问题讨论】: