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

そしてそれは埋め込まれません。

そしてhierはエラーです

/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 に答える