user1405338
user1405338

Reputation: 189

watir webdriver get src of embeded file

hier is the html of embed swf file and src is always unknown (not the same)

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

So I would like to take everything that src attribute has.

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

hier is watir code

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

and it don get it embed.

and hier is error

/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>'

Upvotes: 2

Views: 627

Answers (1)

Željko Filipin
Željko Filipin

Reputation: 57312

Try this:

browser.embed.src

or

browser.embed.attribute_value('src')

Upvotes: 2

Related Questions