watir获取元素的css样式

来源:互联网 发布:java 上传文件到http 编辑:程序博客网 时间:2024/05/29 18:10

给富文本框中的字体添加了各种样式后,可能会在该文字的外围出现一个span,css样式信息在该span中。可以通过下面的方法来获取:

 富文本框赋值:@ie.frame(:id,"editor_ifr").document.body.innerText="内容很精彩"

添加了各种样式后,这样获取各种样式:

    sp=@ie.frame(:id,"editor_ifr").body(:id,"tinymce").p.span
    fontcolor=sp.document.currentStyle.color.to_s  
    bgcolor=sp.document.currentStyle.backgroundcolor.to_s
    udline=sp.document.currentStyle.textdecoration.to_s
    fontfy=sp.document.currentStyle.fontfamily.to_s
    fontsize=sp.document.currentStyle.fontsize.to_s