【问题标题】:How to select Radio button in JQGrid using selenium webdriver如何使用 selenium webdriver 在 JQGrid 中选择单选按钮
【发布时间】:2016-10-05 10:48:10
【问题描述】:

我正在尝试选择 Jqgrid 表中的单选按钮。但我找不到它的 XPath。

 `table id="list" class="ui-jqgrid-btable" tabindex="0" role="grid" aria-
  multiselectable="false" aria-labelledby="gbox_list" style="width: 940px;
  display: table;" cellspacing="0" cellpadding="0" border="0"> 
  <tbody>
  <tr class="jqgfirstrow" role="row" style="height:auto">
  <td role="gridcell" style="height:0px;width:20px;"></td>
  <td role="gridcell" style="height:0px;width:150px;display:none;"></td>
  </tr>
  <tr id="1" class="ui-widget-content jqgrow ui-row-ltr ui-state-highlight 
  gridRowSelect" role="row" tabindex="0" style="color: rgb(255, 0, 0);" 
  aria-selected="true">
  <td role="gridcell" style="text-align:center;" title="" aria-
  describedby="list_myradio">
  <input id="gridRadio" class="gridRadio" name="radio_list" type="radio">
  </td>`

【问题讨论】:

  • 您可以尝试按id定位元素,而不是使用XPah:driver.findElement(By.id("elementId"))。其中elementId 可能是gridRadio。见the documentation

标签: java selenium-webdriver jqgrid


【解决方案1】:

我建议通过其唯一 ID (driver.findElement(By.id("gridRadio"))) 选择它。但如果您明确想要使用 XPath,请使用以下表达式之一:

//input[@id='gridRadio']

//table[@id='list']/tbody/tr[@id='1']/td/input[@type='radio']

【讨论】:

  • 不要忘记在其末尾添加 .click()。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-20
  • 1970-01-01
  • 2014-06-18
  • 1970-01-01
  • 1970-01-01
  • 2023-03-07
  • 2014-06-15
相关资源
最近更新 更多