I have created a small script, where it loops and deletes the unwanted rows in the table, but there is one row in the table that can not be removed. How can I skip that row and move on to the next one?
This is my script:
for(int i=0; i<25; i++){
if(driver.findElement(By.xpath(PvtConstants.READ_ADVERTISRERS_ADVERTISER_IDS)).getText().contains("Skip Me")){
//what to add here to skip the "Skip Me" text????
}
//select the item in the table
driver.findElement(By.xpath(PvtConstants.READ_ADVERTISRERS_ADVERTISER_IDS)).click();
//click the delete button
driver.findElement(By.xpath(".//*[@id='deleteAdv']")).click();
This is what the column looks like. I want to skip RealMedia, and then remove all items before and after.
HTML:
<table class="table smallInput dataTable" id="dataTableAdvertisers" ">
<thead>
<tr role="row" style="height: 0px;">
<th class="sorting_asc" tabindex="0" "></th>
<th class="sorting" tabindex="0" "></th>
<th class="sorting" tabindex="0" "></th>
</tr>
</thead>
<tbody role="alert" aria-live="polite" aria-relevant="all">
<tr class="odd">
<td class="">
<a href="getadvertiserdetailsNew.do?advertiserKey=198909">RealMedia</a></td>
<td class="">---</td>
<td class="">---</td>
<td class="">---</td>
<td class="">---</td>
</tr><tr class="even">
<td class="">
<a href="getadvertiserdetailsNew.do?advertiserKey=198910">teset2</a></td>
<td class="">---</td>
<td class="">---</td>
<td class="">---</td><td class="">---</td>
</tr><tr class="odd">
</tbody>
</table>