2

hier是嵌入swf文件的html,src总是未知的(不一样)

<html>
<body>
<iframe id='main'><!-- first iframe -->
   <iframe ><!--second iframe -->
      <html>
      <body>
         <embed src="some.swf?refdfg" >
      </body>
      </html>
   </iframe>
</iframe>
</body>
</html>

所以我想采用 src 属性所具有的一切。

this is xpath
ifrmae#main/iframe#never same/html/body/div/embed

hier 是 watir 代码

require 'rubygems'
require 'watir-webdriver'
require 'open-uri'
require 'find'
b = Watir::Browser.new
b.goto 'somesite.com'
b.wait
sleep(5)
if b.frame(:id => 'main').frame(:index => 0).exists? #hier I check if second iframe exist
            #hier I want to get src of that embeded swf
    line 39 puts b.frame.(:id => 'main').frame(:index => 0).embed.src
            puts b.frame.(:id => 'main').frame(:index => 0).embed.attribute_value('src')
    end

它没有嵌入它。

他是错误的

/usr/local/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:428:in `method_missing': undefined method `call' for #<Watir::Frame:0x..fa17d220e located=false selector={}> (NoMethodError)
from watir.rb:39:in `<main>'
4

1 回答 1

2

尝试这个:

browser.embed.src

或者

browser.embed.attribute_value('src')
于 2012-11-21T13:41:24.423 回答