如何点击真正是div的单选按钮

时间:2015-03-19 00:28:22

标签: javascript primefaces

我公司正在使用Primefaces JS框架。我正在尝试使用WebDriver单击是单选按钮。但它不是传统的单选按钮。

这是代码,我不知道如何制定WD语句.click()动作?

<td class="ui-panelgrid-cell nc4ui-logistics-values-left" role="gridcell">
<div id="A0588:search-panels:governmentProperty" class="ui-selectonebutton ui-buttonset ui-widget ui-corner-all boolean-value">
<div class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-left">
<input id="A0588:search-panels:governmentProperty:0" class="ui-helper-hidden" type="radio" onchange="nc4uiLogisticsChanged();" value="Yes" name="A0588:search-panels:governmentProperty">
<span class="ui-button-text ui-c">Yes</span>
</div>
<div class="ui-button ui-widget ui-state-default ui-button-text-only ui-corner-right ui-state-active">
</div>
</td>
<td class="ui-panelgrid-cell nc4ui-logistics-labels" role="gridcell">
<td class="ui-panelgrid-cell nc4ui-logistics-values-right" role="gridcell">

我尝试过以下方法但没有成功:

ele = wait.until(ExpectedConditions.elementToBeClickable(By.id("aui_3_4_0_1_1659")));
    ele.click();

    ele = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[contains(.,'aui_3_4_0_1')]")));
    ele.click();

driver.findElement(By.xpath("//span[contains(.,'aui_3_4_0_1')]")).click();

感谢您的帮助......

2 个答案:

答案 0 :(得分:0)

HTML中的ID“aui_3_4_0_1_1659”在哪里?找不到它.... HTML中单选按钮的ID是“A0588:search-panels:governmentProperty:0”。也许是这个问题?

答案 1 :(得分:0)

这是我最终的结果:

ele = driver.findElement(By.cssSelector(“[id $ = governmentProperty] div:not(.ui-state-active)span.ui-button-text”));