【问题标题】:selecting radio button with highest value选择具有最高值的单选按钮
【发布时间】:2017-01-02 07:31:10
【问题描述】:

我需要根据相应的值在单选按钮列表中选择一个单选按钮。考虑到开始时的“点”是单选按钮,针对它的值是从数据库中提取的。我需要选择其中值最高的单选按钮。第一列名称和第二列年龄。

  • 公羊 | 25
  • 西塔 | 32
  • 拉克斯曼 | 34

当我在 selenium 中运行时......程序应该再次选择单选按钮 laxman,因为它具有最高的年龄值

【问题讨论】:

  • 您能否分享这些单选按钮的 HTML 以便更好地理解??
  • @saurabh gaur <td align="center" style="background-color:#EFEFEF;"> <input id="ccMain_grdstock_rdselstckpoint_3" type="radio" onclick="javascript:SelectSingleRadiobutton(this.id);setTimeout('__doPostBack(\'ctl00$ccMain$grdstock$ctl05$rdselstckpoint\',\'\')', 0)" value="rdselstckpoint" name="ctl00$ccMain$grdstock$ctl05$rdselstckpoint"/> </td> <td align="center" style="background-color:#EFEFEF;"> 4 </td>

标签: java selenium testing


【解决方案1】:

此 Xpath 将帮助您获得更高价值的无线电元素。我正在使用preceding-siblingfollowing-sibling,但您可以根据需要更改它,或者匹配您未提供的 html 代码。

//input[@type='radio' and not(preceding-sibling::input[@type='radio']/@value>= @value) and not(following-sibling::input[@type='radio']/@value > @value)]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-24
    • 1970-01-01
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多