尝试验证 CSS 样式中对象的背景属性

发布于 2024-11-15 05:04:53 字数 915 浏览 9 评论 0原文

  • 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一个人的夜不怕黑 2024-11-22 05:04:53

我能够通过使用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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文