Home:ALL Converter>Protractor getting DOM element and using their properties

Protractor getting DOM element and using their properties

Ask Time:2018-01-23T18:45:34         Author:JiggyJinjo

Json Formatter

I'm running e2e tests with Protractor and Selenium on a Polymer/Angular App. Most of the elements are in the shadow DOM (I managed to handle it with custom css locators but it made my tests unstable as any change in the dom breaks them). The problem is that the devs have implemented a virtual scroll list : Only a few items are loaded in the scroll list, next ones are loaded when you scroll. I asked my devs how to deal with it and they told me I had to get the web-component and test it without protractor aka running commands like this :

document.querySelector('virtual-scroll').baseList

Where baseList is a public property of the tag. I tried

var element = browser.executeScript('return document.querySelector("virtual-scroll")');
element.then(function (el){
  console.log(el.$.baseList);
});

but the command above returns a WebElement. Is there any way to return the HTML DOM element as a javascript querySelector command does ?

EDIT : as requested the source code with the property of the scrollList that I want to get enter image description here

Author:JiggyJinjo,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48399745/protractor-getting-dom-element-and-using-their-properties
yy