[英]How to verify that a word is Bold in selenium webdriver using Java?
I have a web application.I have a scenario that a search term becomes bold in some pages so i need to verify whether the search term is Bold or not. 我有一个Web应用程序。我有一个场景,在某些页面中搜索词会变为粗体,因此我需要验证搜索词是否为粗体。 I have tried the following code but i am not able to verify:
我尝试了以下代码,但无法验证:
String colour = driver.findElement(By.className("classname")).getCssValue("color");
if(colour.contains("rgba(46,46,46,1)"))
System.out.println("Term is Bold");
else
System.out.println("Term is not Bold");
The bold value of a font is expressed using the font-weight
CSS property 字体的粗体值使用
font-weight
CSS属性表示
String fontWeight = driver.findElement(By.className("classname"))
.getCssValue("font-weight");
boolean isBold = "bold".equals(fontWeight) || "bolder".equals(fontWeight) || Integer.parseInt(fontWeight) >= 700;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.