简体   繁体   English

如何使用Java在Selenium Webdriver中验证单词是否为粗体?

[英]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.

相关问题 如何使用Java验证Selenium WebDriver中的tooltipText - How to verify tooltipText in Selenium WebDriver using Java 如何使用Java使用Selenium WebDriver检查标签是否为粗体? - How to check if a label is bold with Selenium WebDriver using Java? 如何在网页上使用带有 Java 的 Selenium WebDriver 验证工具提示文本 - How to verify tooltip text using Selenium WebDriver with java on a webpage 如果对象在Selenium Webdriver Java中不可见,如何使用xpath验证对象 - how to verify object using xpath if object is invisible in selenium webdriver java 如何使用Java使用Selenium WebDriver验证是否单击了按钮 - How to verify whether a Button is clicked or not with Selenium WebDriver using Java 使用Java在Selenium WebDriver中发布后,每次如何验证文本? - How to verify text everytime after posting with Selenium WebDriver using java? 如何使用Java使用Selenium WebDriver验证动态库? - How to verify dynamic gallery with Selenium WebDriver using Java? 如何在Selenium Java Webdriver中验证图像的尺寸? - How to verify dimensions of image in Selenium Java Webdriver? 如何验证特定文本下的文本 <DIV> 使用Selenium WebDriver(java)和Chrome浏览器标记? - How can I verify presence of text under a specific <DIV> tag using Selenium WebDriver (java) and Chrome? 如何使用Java验证与Selenium WebDriver中的UI选项匹配的下拉选项? - How to verify the dropdown options matching with the UI options in selenium WebDriver using Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM