selenium how to verify character font?

走远了吗. 提交于 2019-12-12 06:54:16

问题


the problem as the title.


回答1:


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);


来源:https://stackoverflow.com/questions/3234670/selenium-how-to-verify-character-font

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!