How to find a child element in protractor?

I have a parent element called by xpath and I want to get its child elements through a CSS class, I am getting the following error: Failed: element(...).element.all is not a function

I am trying to get the items as follows:

var licenses_grid = await element(
 by.xpath(browser.params.constants.GENERALPATHS.LICENSES.LICENSESGRID)
).element.all(by.className('ui-grid-cell-contents ng-binding ng-scope'));

What am I doing wrong?

Upvotes: 0

Views: 113

Answers (2)

tehbeardedone
tehbeardedone

Reputation: 2858

You should use the shorthand notation instead. $ for element(by.css()) and $$ for element.all(by.css()). You also don't need await here.

Your code should be something like this:

var licenses_grid = element(
  by.xpath(browser.params.constants.GENERALPATHS.LICENSES.LICENSESGRID))
    .$$('.ui-grid-cell-contents.ng-binding.ng-scope'));

Upvotes: 1

Joaquin Casco
Joaquin Casco

Reputation: 734

you don't need to await when declaring an element variable

Try this:

var parent = element(by.xpath(browser.params.constants.GENERALPATHS.LICENSES.LICENSESGRID));
var child = parent.all(by.className('ui-grid-cell-contents ng-binding ng-scope'));

Upvotes: 1

Related Questions