gpt4 book ai didi

java - 如何根据提供的 HTML 验证单选按钮是否被选中?

转载 作者:行者123 更新时间:2023-12-02 10:57:14 25 4
gpt4 key购买 nike

这是所选单选按钮的 html 代码

<input name="blooms_level" value="4" id="blooms_level4" class="radio " checked="" type="radio">

我尝试了下面的代码,它返回 null

String str = driver.findElement(By.xpath("xpathValue")).getAttribute("checked");
str.equalsIgnoreCase("true");

请建议任何替代方法,因为检查的值为空

最佳答案

尝试下面提到的 Java 代码:

Boolean radioSelected= driver.findElement(By.xpath("xpathValue")).isSelected();
if (radioSelected)
{
System.out.println("Radio Button is selected");
}else{
System.out.println("Radio Button is not selected");
}

关于java - 如何根据提供的 HTML 验证单选按钮是否被选中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51632054/

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