【发布时间】:2017-01-06 20:13:23
【问题描述】:
我已经写了下面的代码来选择单选按钮,它工作正常,但今天它不工作。请找到代码和相应的错误消息
代码1:
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement radio = wait.until (ExpectedConditions.presenceOfElementLocated(By.id("0_2485A_StartDate")));
((JavascriptExecutor)driver).executeScript("arguments[0].click()", radio);
错误1: '线程“main” org.openqa.selenium.TimeoutException 中的异常:等待 10 秒后超时,等待存在以下元素:By.id: 0_2485A_StartDate'
代码2:
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement radio = wait.until (ExpectedConditions.presenceOfElementLocated(By.id("Radio_0_2485A")));
((JavascriptExecutor)driver).executeScript("arguments[0].click()", radio);
错误2: '线程“main”中的异常 org.openqa.selenium.TimeoutException:等待 10 秒后超时,等待由以下位置的元素存在:By.id:Radio_0_2485A'
代码3:
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement radio = wait.until(ExpectedConditions.elementToBeClickable(By.id("0_2485A_StartDate")));
radio.click();
错误3: '线程“main”中的异常 org.openqa.selenium.TimeoutException: 等待元素可点击 10 秒后超时:By.id: 0_2485A_StartDate'
代码4:
WebDriverWait 等待 = 新的 WebDriverWait(驱动程序,10); WebElement radio = wait.until(ExpectedConditions.elementToBeClickable(By.id("Radio_0_2485A"))); radio.click();
错误4: '线程“main” org.openqa.selenium.TimeoutException 中的异常:等待元素可点击 10 秒后超时:By.id: Radio_0_2485A'
HTML:
<th class="radio">
<input id="0_2485A_StartDate" type="hidden" value="18/12/2015 00:01:00">
<input name="Products[0].ProductCode" title="5 Year Fixed Rate Until 28/02/2021 with £999 Fee" id="Radio_0_2485A" type="radio" value="2485A">
<label for="Radio_0_2485A">
5 Year Fixed Rate Until 28/02/2021 with £999 Fee
</label>
</th>
请提出建议。
【问题讨论】:
-
不,它不是动态生成的。