开发者

selenium how to verify character font?

the proble开发者_JAVA技巧m as the title.


You should get the value of "font-weight" CSS property. In IE the bold value is "700" while in Firefox it will be "bold".

You need to get the computed style (FF) or current style (IE) of the element.

So for IE you will need to execute the following (it is in Java):

String strBold = selenium.getEval("var el = this.browserbot.findElement(<locator>);bold = el.currentStyle.fontWeight;");
boolean bold = "700".equals(strBold);

For the Firefox:

String strBold = selenium.getEval("var el = this.browserbot.findElement(<locator>);bold = window.document.defaultView.getComputedStyle(el,null).getPropertyValue('font-weight');");
boolean bold = "bold".equals(strBold);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜