图片中的CSS元素解析验证

上一篇 / 下一篇  2010-12-21 14:09:11 / 个人分类:自动化测试

登录http://shopping.dangdang.com/shoppingcart/shopping_cart.aspx  

如果想要解析其中的页头,可以通过获取此图片的纵坐标来解析。

第一步,通过firebug将该页头的对应样式打开。


然后 先获取此图片的background地址(eg: ../images/bg_cart_title.gif),然后和域名拼接 http://shopping.dangdang.com/shoppingcart/images/bg_cart_title.gif,然后打开,就可以看到图片

 

 第二步,获取图片的URL,

thisstyle. = @ie.element_by_xpath("//div[contains(@class,'shoppingcart_nav')]/h1")

      temp = thisstyle.currentStyle.backgroundimage

   结果为“http://shopping.dangdang.com/shoppingcart/images/bg_cart_title.gif

 

 第三步,获取该URL的Y坐标

["http://shopping.dangdang.com/shoppingcart/images/bg_cart_title.gif", "0px"]

      thisstyle. = @ie.element_by_xpath("//div[contains(@class,'shoppingcart_nav')]/h1")

      temp = thisstyle.currentStyle.backgroundimage

      temp_position = thisstyle.currentStyle.backgroundPositionY

   结果为 "0px"

 这样的话,就可以将该元素的Y坐标以及图片URL存放到数组,进行自动化比对。到此,大功告成。


TAG:

 

评分:0

我来说两句

Open Toolbar