gpt4 book ai didi

c# - Selenium - 查找应用的 CSS 样式

转载 作者:行者123 更新时间:2023-11-28 04:35:38 26 4
gpt4 key购买 nike

我有一个网页,上面有一个字段。可以使用配置面板设置字段值。可以通过勾选复选框将该字段标记为必填。这将样式应用于字段标签。现在我的问题是使用 selenium 我如何发现此样式已应用于控件标签?

    .form-group.required div.title label:after, .form-group.required label.title:after {
content: '*';
margin-left: 5px;
color: #FF7900;

最佳答案

您可以尝试使用 getAttribute() 来实现您的场景

<input name="Name Locator" value="selenium">Hello</input>

driver.findElement(By.name("Name Locator")).getAttribute("value")

这里 getAttribute() 获取值为“Selenium”的属性的数据。返回:属性的当前值,如果未设置该值,则返回 null。

关于c# - Selenium - 查找应用的 CSS 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41497309/

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