-1
  • 红宝石版本 1.9.2
  • 宝石版本 1.8.1
  • 兼容模式下的 IE 版本 8

我在页面上有一个对象(实际上是表格中的一个单元格),它在 DOM (HTML) 中定义为“TD class=burst>100<”。还附加了一个 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 样式中访问对象的背景属性/方法的方法?

4

1 回答 1

0

我能够通过使用 backgroundimage 属性而不是 background 属性来访问我需要的信息(因为 background 属性由多个属性组成,包括 backgroundimage 属性)。

于 2011-06-24T15:37:18.857 回答