首页 > 解决方案 > 无法使用 Selenium Java 单击单选按钮

问题描述

<table width="100%" border="0" cellpadding="0" cellspacing="0" id="radioTypeTable" class="radioTable">
						<tbody><tr id="transactionType">				
							
		 						
						 			<td align="left" style="width:12px;"><input type="radio" name="preliminaryApplication_TransactionType" tabindex="200" value="1" checked="checked" onclick="clearFSProgramsOnChangeOfTransType();resetDlrPreferredFs();changeTransactionType(this);" id="preliminaryApplication_TransactionType_1" class=""></td>
									<td align="left" class="transtypeLabel"><strong><label id="preliminaryApplication_TransactionType_1_label" for="preliminaryApplication_TransactionType_1">Option1</label></strong></td><td style="width:5%;">&nbsp;</td>

						 			<td align="left" style="width:12px;"><input type="radio" name="preliminaryApplication_TransactionType" tabindex="200" value="2" onclick="clearFSProgramsOnChangeOfTransType();resetDlrPreferredFs();changeTransactionType(this);" id="preliminaryApplication_TransactionType_2"></td>
									<td align="left" class="transtypeLabel"><strong><label id="preliminaryApplication_TransactionType_2_label" for="preliminaryApplication_TransactionType_2">Option2</label></strong></td><td style="width:5%;">&nbsp;</td>
 	
						</tr>			
						<tr>
							<td align="left" colspan="10">

							</td>				
						</tr>          
					</tbody></table>

我有一个页面,其中包含多个单选按钮,默认情况下选择一个特定的单选按钮开始。在尝试单击任何其他 Radio 时,它根本不起作用,并且移动得更远而不会失败。到目前为止我尝试过的事情:

动作类“双击”

Actions actions = new Actions(driver);
actions.doubleClick(element).perform();

动作类“moveToElement”,然后单击

Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.click();
actions.build().perform();

Javascript 执行器点击

((JavascriptExecutor) driver).executeScript("arguments[0].click();", element); 

甚至尝试在while循环中单击

到目前为止没有任何效果。此按钮之前和之后页面上的所有其他内容都可以正常工作。我也在寻找任何可能的 iFrame。单击按钮时,我可以看到按钮变为蓝色。但是,点击不粘。我也给予了足够的隐式和显式等待来尝试。我还检查了按钮是否可见。有什么建议么。

标签: javaselenium-webdriver

解决方案


推荐阅读