hier是embed 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 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
它不会嵌入它。
和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>'
答案 0 :(得分:2)
试试这个:
browser.embed.src
或
browser.embed.attribute_value('src')