【问题标题】:How do I find an element nested in I-frames?如何找到嵌套在 I-frame 中的元素?
【发布时间】:2012-12-11 19:44:47
【问题描述】:

我想测试一封电子邮件的正文。

它使用 3 个 i 帧深度的 FCK 编辑器。

<...name="fancybox-frame"...>
    <iframe>
        <iframe>
             <body>H E R E  I S  W H A T   I   W A N T  T O   A C C E S S</body>
        </iframe>
    </iframe>
</[fancybox-frame]>

除了模棱两可的乐趣,我如何多次使用帧内。

如果我用这个...

within_frame('fancybox-frame') do
fill_in('frm_subject', :with => eventname + ' email')
within_frame('iframe[id="frm_message___Frame"]') do
  within_frame('iframe') do
    fill_in('body', :with => 'Event email for ' + now.to_s)
  end
end

结束

我明白了……

      switchFrame execution failed;
   INVALID_EXPRESSION_ERR: DOM XPath Exception 51 (Selenium::WebDriver::Erro
r::WebDriverError)
  ./features/step_definitions/RCST08_steps.rb:96:in `block (2 levels) in <to
p (required)>'
  ./features/step_definitions/RCST08_steps.rb:94:in `/^select a message to s
end\.$/'
  features\RCST08.feature:26:in `And select a message to send.'

有什么想法吗?

【问题讨论】:

  • 你有嵌套 2 度深的 iframe id 吗?如果是,则切换到它,然后执行您的操作

标签: html ruby selenium cucumber capybara


【解决方案1】:

在您“切换”到它之前,Selenium 无法处理框架(

within_frame('fancybox-frame') do
  fill_in('frm_subject', :with => eventname + ' email')
  within_frame('iframe[id="frm_message___Frame"]') do
    within_frame('...name of outer iframe...') do
      within_frame('...name of inner iframe...') do
        fill_in('body', :with => 'Event email for ' + now.to_s)
      end
    end
  end
end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-24
    • 2021-03-15
    • 1970-01-01
    • 2017-01-31
    • 1970-01-01
    • 2022-11-15
    相关资源
    最近更新 更多