gpt4 book ai didi

java - BAD : need suggest on selenium using radio button select. 有三个单选按钮。需要选择适当的。但出现错误

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

我正在开发一个门户网站,我们可以在其中从三个单选按钮中选择凭证类型。它不起作用:我收到错误。

import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Vouchertest {

public static void main(String[] args) {

WebDriver driver=new FirefoxDriver();
Logger log = Logger.getLogger("devpinoyLogger");
driver.get("url");
log.debug("entring username");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id='UserName']")).sendKeys("xoxo");
log.debug("entering password");
driver.findElement(By.xpath("//*[@id='Password']")).sendKeys("Password123");
log.debug("Clicking login");
driver.findElement(By.xpath("//*[@id='loginForm']/form/div[4]/div/input")).click();
log.debug("Clicking voucher");
driver.findElement(By.xpath("html/body/nav/div[2]/div[2]/ul/li[2]/a")).click();
log.debug("Clicking create_voucher");
driver.findElement(By.xpath("//*[@id='main']/a[1]")).click();
**log.debug("Clicking voucher_type");
driver.findElement(By.cssSelector("input[value='card']")).click();

}

}

这里是 html 代码:

<input id="VoucherType" type="radio" value="Corporate" name="VoucherType">
<label for="Corporate_Certificate">Corporate Certificate</label>
<input id="VoucherType" type="radio" value="Card" name="VoucherType">
<label for="Gift_Card">Gift Card</label>
<input id="VoucherType" type="radio" value="Adv" name="VoucherType">
<label for="Advanced_Payment">Advanced Payment</label>

这是跟踪:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":"input[value='card']"}
Command duration or timeout: 30.12 seconds

最佳答案

在 HTML 代码中,“Card”以大写字母开头,而在 Java 代码中,它的写法如下:“input[value='card']”

关于java - BAD : need suggest on selenium using radio button select. 有三个单选按钮。需要选择适当的。但出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33799115/

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