Read the error message: the element is not visible.
It has nothing to do with your XPath not finding the element. It finds
the element and it is present BUT it is not visible. For example, if
the code was:
WebElement we = driver.findElement(By.xpath("//
td[text()='SM_ONBOARD_SERVICE']/preceding::td/div"));
System.out.println(we.isDisplayed());
It would print false because the element is not visible. You probably
have to do something to enable the radio button before you can
interact with it. Remember that you are simulating a manual tester. If
I have to enable a checkbox before I can select the radio button then
WebDriver needs to enable the checkbox before it can select the radio
button.
On Jun 5, 1:33 am, parikshit chakraborty <
itsmyzones...@gmail.com>
wrote:
> Hello All,
>
> I have an HTML as below where I need to find out Radio Button for an item "*
> SM_ONBOARD_SERVICE*". When I filter using SM_ONBOARD_SERVICE, I get two
> item rows in the table viz. *SM_ONBOARD_SERVICE & **SM_ONBOARD_SERVICE_PLAN.
> *
> *
> *
> The XPath I am using to check the radio button pertaining to *SM_ONBOARD_SERVICE
> *is as below:
>
> *
> //td[./text()='SM_ONBOARD_SERVICE']/preceding-sibling::td/div*
> *
> *
> Above XPath works absolutely fine when I try it using XPath checker or
> FirePath and is returning me only one match. But when I execute the script
> it fails saying that the element is not visible.
>
> I cannot use * //td[contains(text(),'SM_ONBOARD_SERVICE')]/preceding-sibling::td/div
> * as it returns 2 matches always, radio buttons for both *SM_ONBOARD_SERVICE
> & **SM_ONBOARD_SERVICE_PLAN*
>
> *HTMLSnippet:*
> *
> *
> <div class="dojoxGridRow" role="row" aria-selected="false" style="">
> <table class="dojoxGridRowTable" cellspacing="0" cellpadding="0" border="0"
> role="presentation" style="width: 503px;">
> <tbody>
> <tr>
> <td class="dojoxGridCell " style="text-align: center;width:30px;" idx="0"
> role="gridcell" tabindex="-1">
> <div id="dojox_grid_EnhancedGrid_1_rowSelector_0"
> class="dojoxGridRowSelector dijitReset dijitInline dijitRadio"
> aria-label="Row 1, single selection, radio box" aria-disabled="false" aria-
> pressed="false" role="presentation"
> name="dojox_grid_EnhancedGrid_1_rowSelector" tabindex="-1">
> <span class=" dojoxGridRowSelectorStatusText">O</span>
> </div>
> </td>
> <td class="dojoxGridCell " style="display:none;width:5%;" idx="1"
> role="gridcell" tabindex="-1">...</td>
> <td class="dojoxGridCell " style="width:auto;" idx="2" role="gridcell"
> tabindex="-1">*SM_ONBOARD_SERVICE*</td>
> tabindex="-1">*SM_ONBOARD_SERVICE_PLAN*</td>
> <td class="dojoxGridCell " style="width:auto;" idx="3" role="gridcell"
> tabindex="-1"/>
> </tr>
> </tbody>
> </table>
> </div>
>
> Please help me in getting the exact XPath for *SM_ONBOARD_SERVICE.*
> *
> *
> *
> *
> Regards,
> Parikshit