0

I'm trying to locate the following using element(by.id()) :

element(by.id('#1484755825715-7-uiGrid-0007-cell'))

Using Protractor interactive cmd line, it returns No element found...

> element(by.id('#1484755825715-7-uiGrid-0007-cell')).getText()
NoSuchElementError: No element found using locator: By(css selector, *[id="\#1484755825715-7-uiGrid-0007-cell"])

Yet in f12 Chrome console tools, the following jQuery selector finds the same element by div id:

 $('#1484755825715-7-uiGrid-0007-cell')[0]
<div ng-repeat=​"(colRenderIndex, col)​ in colContainer.renderedColumns track by col.uid" ui-grid-one-bind-id-grid=​"rowRenderIndex + '-' + col.uid + '-cell'" class=​"ui-grid-cell ng-scope ui-grid-coluiGrid-0007 amt bold-text sub-total" ng-class=​"{ 'ui-grid-row-header-cell':​ col.isRowHeader }​" role=​"gridcell" ui-grid-cell id=​"1484755825715-7-uiGrid-0007-cell">​…​</div>​

I also tried using by.css ('#1484...-cell > div'), but that doesn't work either.

So, I know the element exists but Protractor is NOT finding it. Is the id string too long ?

Advice appreciated....

****** UPDATE ******* I was using hash '#' symbol in by.id(), which is wrong.

bob.mazzo
  • 5,183
  • 23
  • 80
  • 149
  • 1
    Are you sure the `id` value is not auto-generated every time? – alecxe Jan 18 '17 at 16:17
  • @alecxe - yes they are generated for each application instance. @Barney - yes, I believe that was the issue. I had removed the `#` before, but it wasn't working. – bob.mazzo Jan 18 '17 at 16:23
  • 2
    @Barney, correct answer – bob.mazzo Jan 18 '17 at 16:32
  • 1
    Oh nice, I'll warn about this statically in the future to catch this kind of errors early (https://github.com/alecxe/eslint-plugin-protractor/issues/67). Thanks for the inspiration :) – alecxe Jan 18 '17 at 16:35
  • @bob.mazzo glad it helped :) By Mistake I deleted my comment though – Barney Jan 18 '17 at 16:53
  • @alecxe, my dumb mistake again, but hopefully it will help someone. Thanks for jumping in. Barney needs to add his official answer. – bob.mazzo Jan 18 '17 at 17:54

0 Answers0