2
votes

I have the scoured the internet to get an answer for this but couldn't find one.

How can you get the data attached to an element from a protractor test?

element(by.css('path')) returns an object with a few methods such as getText(), count() etc but there is no way I can get the data attached to the path.

I need this to get the depth of the path and then click on a correct path with desired depth.

I can of course attached an attribute to the <path> e.g. <path data-depth=3> but I don't want to add an attribute just so I can write E2E tests

Any help would be appreciated.

1
Could you make the problem more specific - provide the HTML code and the desired element/data you want to locate? Thanks. - alecxe
If anyone is looking for solution for a similar problem see fiddle here - jsfiddle.net/hsuh/euom9fpa/4 - hsubi

1 Answers

0
votes

You could run a script in the browser and get the data from it:

browser.executeScript("return d3.select(your_element).data()").then(function(data) {
  // work with data
});