-3

I am trying to verify a value from a specific column in a huge web table. But none of the locator is unique and selenium cant find all the element. using selenium and cucumber jvm.

below is one of the html code for a cell value:

<div id="1504183962844-0-uiGrid-03UI-cell" class="ui-grid-cell ng-scope ui-grid-coluiGrid-03UI" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid="rowRenderIndex + '-' + col.uid + '-cell'" ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader }" role="gridcell" ui-grid-cell="" tabindex="-1">
<div class="ui-grid-cell-contents ng-binding ng-scope">ncautoemail_dtyhe@gmail.com</div>

it has around 80 cell in the row and id keep changing. any advice on locating element and verify the value.

Rumon
  • 1
  • 1

1 Answers1

0

Try below :-

//div[@id='1504183962844-0-uiGrid-03UI-cell' and @class='ui-grid-cell ng-scope ui-grid-coluiGrid-03UI' and @role='gridcell']

And

//div[class='ui-grid-cell-contents ng-binding ng-scope']/preceding-sibling::div[@@id='1504183962844-0-uiGrid-03UI-cell']

Or

(//div[@id='1504183962844-0-uiGrid-03UI-cell' and @class='ui-grid-cell ng-scope ui-grid-coluiGrid-03UI' and @role='gridcell'])[14]

Hope it will help you :)

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
  • Thanks for your ans. But the id always change so 2nd time it cudnt find with the same path. – Rumon Aug 31 '17 at 18:46
  • You can remove id from my path .. I have put other parameters ... May they will help you.. I have compined them with and operator – Shubham Jain Aug 31 '17 at 18:47
  • there are still another 40 column with the same parameter (class,role). And if I put it in List of element and iterate thru it found only 12 element, the rest is not visible in the table untill I scroll to the right. And javascript scroll to the element also doesnt work cause it doesn find a specific element. – Rumon Aug 31 '17 at 18:52
  • What is the position of your required element? Can you specify the position and check if the next time the position is not change then I can help you on same – Shubham Jain Aug 31 '17 at 18:54
  • If you know the position I have added a sample xpath which will select your element on 14th position .. change as per your required element .. array in xpath is started from 1 so don't use -1 logic here – Shubham Jain Aug 31 '17 at 18:57
  • Yeah the position doesnt change. It stays in the same place always. and I cant scroll to that bcz that responsive table is in separate div. I tried clicking any of the element on that div and tried to scroll to the right but didnt work. – Rumon Aug 31 '17 at 18:59
  • Can you upload your html page source to any place and provide a link to me .. I will generate a xpath for you – Shubham Jain Aug 31 '17 at 19:02
  • yeah that sample xpath works for first matching 12 element. but for the 24th element it doesnt find it cause of the scrolling. – Rumon Aug 31 '17 at 19:07
  • Then scroll you page by providing focus – Shubham Jain Aug 31 '17 at 19:08