尝试验证 CSS 样式中对象的背景属性
- Ruby 版本 1.9.2
- gem 版本 1.8.1
- IE 版本 8 兼容模式
我在页面上有一个对象(实际上是表中的一个单元格),它被定义为“TD class=burst>100<”在 DOM (HTML) 中。 还附加了一个 CSS,其中包含该对象的多个样式属性(例如颜色、文本对齐)。 CSS 样式代码如下所示:
DIV.points TD.burst
text-align : center
width : 55px
...
background : url(xxxx.png) no-repeat 50% 0px
color : #fff
...
对象的样式背景属性正在页面上显示图像。
我正在尝试使用 watir 验证是否显示正确的图像,因此我正在尝试检索背景属性:
image_id = $ie.cell(:class=>"burst",:index=>1).style.background
我收到 method_missing': Unknown property or method: `background' (NoMethodError) 错误。
我可以获得其他属性,例如:
image_id = $ie.cell(:class=>"burst",:index=>1).style.width
image_id = $ie.cell(:class=>"burst",:index=>1).style.color
currentstyle
会出现相同的结果。
有谁知道我可以在 CSS 样式中访问对象的背景属性/方法吗?
- Ruby version 1.9.2
- gem version 1.8.1
- IE version 8 in compatibility mode
I have an object on the page (is actually a cell in a table) that is defined as a "TD class=burst>100<" in the DOM (HTML).
There is a CSS attached as well with several style properties for that object (e.g. color, text-align).
The CSS style code looks like the following:
DIV.points TD.burst
text-align : center
width : 55px
...
background : url(xxxx.png) no-repeat 50% 0px
color : #fff
...
The style background property of the object is displaying an image on the page.
I am trying to validate that the correct image is being displayed using watir, so I am trying to retrieve the background property:
image_id = $ie.cell(:class=>"burst",:index=>1).style.background
I am getting a method_missing': unknown property or method: `background' (NoMethodError) error.
I am able to get other properties like:
image_id = $ie.cell(:class=>"burst",:index=>1).style.width
image_id = $ie.cell(:class=>"burst",:index=>1).style.color
The same results occur for currentstyle
.
Does anyone know a way I would be able to access the background property/method of the object when it is in the CSS style?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过使用backgroundimage属性而不是background属性来访问我需要的信息(因为background属性由包括backgroundimage属性在内的多个属性组成)。
I was able to access the information I needed by using the backgroundimage property instead of the background property (since the background property is made up of several properties including the backgroundimage property).