【问题标题】:Not able to click on a button,which is inside an iframe in chrome browser using webdriver无法单击按钮,该按钮位于使用 webdriver 的 chrome 浏览器中的 iframe 内
【发布时间】:2014-12-12 10:00:52
【问题描述】:

在上面的 HTML 页面中,我可以点击 Internet Explorer 中的“选择文件”按钮

@browser.frame(:name, 'fileUI').file_field(:name, 'isoFile').set(path)

当我尝试对 chrome 浏览器使用相同的代码时,它无法正常工作并出现以下错误: 有什么方法可以点击这个按钮?

【问题讨论】:

  • 您遇到了哪个错误?
  • 我不了解 ruby​​ 绑定,但此链接可能会帮助您切换到框架,然后与元素交互:https://code.google.com/p/selenium/wiki/RubyBindings
  • @Helping Hands- 粘贴了错误消息,上面写着 UnknownFrameException

标签: ruby google-chrome selenium watir-webdriver


【解决方案1】:

在 Watir-Webdriver v0.6.5 中,对定位框架的工作方式进行了更改:

  • 之前(即 0.6.5 之前),browser.frame 位于 frame 和 iframe 元素。
  • 现在,browser.frame 定位框架元素,browser.iframe 定位 iframe 元素。

由于您正在处理 iframe,因此您需要使用 iframe 而不是 frame 方法:

@browser.iframe(:name, 'fileUI').file_field(:name, 'isoFile').set(path)

这与 Internet Explorer 一起工作的原因可能是由于使用了 Watir 元数据。 Watir gem 将在使用 IE 时加载 Watir-Classic,在使用其他浏览器时加载 Watir-Webdriver。 frame 方法的更改仅在 Watir-Webdriver 中进行,在 Watir-Classic 中尚未更改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-08
    相关资源
    最近更新 更多