gpt4 book ai didi

java - 如何验证 Selenium 中某个字段的大胆外观

转载 作者:搜寻专家 更新时间:2023-11-01 01:36:55 25 4
gpt4 key购买 nike

我正在尝试自动化手动脚本(在 java 中使用 selenium)来检查网页上某个字段(标签:代表必填字段)的粗体外观。有什么可能的 selenium java 函数来验证某个元素的粗体外观(在类中没有关于外观的信息)

最佳答案

通过 WebDriver(在 Java 中),您可以使用 getCssValue() .

import static org.junit.Assert.assertTrue;
(...)

// assuming elem is a healthy WebElement instance, your found element
String fontWeight = elem.getCssValue("font-weight");
assertTrue(fontWeight.equals("bold") || fontWeight.equals("700"));

(since 700 is the same as bold)


使用 Selenium RC,请参阅 this technique ,只需使用 font-weight(或 fontWeight,具体取决于用途)。

关于java - 如何验证 Selenium 中某个字段的大胆外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10100438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com