Watir-Webdriver Frame Attributes Not Congurent with Other Sources

微笑、不失礼 提交于 2019-12-11 14:32:35

问题


I have an issue where if I return the some attributes of a frame they do not match those in Firebug for example. The reason is that I am looking for a way to identify the purpose of a frame. For example on www.cnet.com they load 19 frames in total and some of these are HTML with JavaScript. I want to inspect some of the frames but not all.

Using Firebug I see some interesting attributes regarding the frame and I want filter the frame based on some of these attributes.

I have the following Ruby code to example the attributes I require:

puts "Tag name: " + frame.attribute_value("tagName")
puts "Local name: " + frame.attribute_value("localName")
puts "Node name: " + frame.attribute_value("nodeName")

The output is as follows:

Tag name: IFRAME
Local name: iframe
Node name: IFRAME

This, however is the output from Firebug for childNodes/Children for the page www.cnet.com:

If I refer to Firebug the first item on the list has the following attributes:

Tag name: DIV
Local name: div
Node name: DIV

BTW, I am using water-webdriver with headless under Firefox on Linux.

Any help is appreciated.


回答1:


The answer is you're not asking for the same attribute that Firefox is showing you.

Taking the case of the DIV that is at the top of your list, if you wanted Watir to return "gigya_ruler" then you'd have to ask for the div's ID attribute, not the name.

Same goes for the twitter hub frame.

Converting all this to Watir code would look like the following:

@b = Watir::Browser.new :ff

div = @b.div(index: 0)
puts div.id # => 'gigya_ruler'

frame = @b.iframe(index: 0)
puts frame.id # => 'twttrHubFrameSecure'


来源:https://stackoverflow.com/questions/19617056/watir-webdriver-frame-attributes-not-congurent-with-other-sources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!