0
votes

I'm writting e2e tests for a Angular/Polymer app (thus using web-components). Is it possible to have access to DOM properties as in : $0.selectedItem? I tried using :

elem = browser.executeScript('return document.querySelector("my-scrollList")');

and then calling

elem .then(function (el){
    console.log(el.selectedItem);
});

But it doesn't work.

However, if I call the property directly from the executeScript command like so it works but it is very tedious :

elem = browser.executeScript('return document.querySelector("my-scrollList").selectedItem');

Is there a way to access DOM properties through WebElements or Protractor API ?

Thanks in advance.

2

2 Answers

1
votes

With a CSS selector by selecting the selected attribute among the <option>:

$("my-scrollList").$("option[selected]")

or :

$("my-scrollList option[selected]")
0
votes

Probably you want to calls to $ by chained to find element within a parent. Take a look at Protractor API . Your code, probably, should look like this one:

elem.then(function (el){
    console.log(el.$('selectedItem'));
});