I have the following code:
//html
<div>
<span>Sort Order</span>
<select id="sortOrderSelect">
<option value=0>Descending</option>
<option value=1>Ascending</option>
</select>
</div>
//test
it('Check it has 2 options', function () {
var selectCount = element.all(by.xpath('//*[@id="sortOrderSelect"]/child::node()'));
expect(selectCount.count()).toBe(2);
});
I am getting the error below. Can someone explain to me what does the error means? And how can I solve it?
InvalidSelectorError: The result of the xpath expression "//*[@id="sortOrderSelect"]/child::node()" is [object Text]. It should be an element.
I have the following code:
//html
<div>
<span>Sort Order</span>
<select id="sortOrderSelect">
<option value=0>Descending</option>
<option value=1>Ascending</option>
</select>
</div>
//test
it('Check it has 2 options', function () {
var selectCount = element.all(by.xpath('//*[@id="sortOrderSelect"]/child::node()'));
expect(selectCount.count()).toBe(2);
});
I am getting the error below. Can someone explain to me what does the error means? And how can I solve it?
Share Improve this question asked Sep 13, 2014 at 13:00 user2678324user2678324 1InvalidSelectorError: The result of the xpath expression "//*[@id="sortOrderSelect"]/child::node()" is [object Text]. It should be an element.
- 1 Browsers may insert empty text nodes when there are newlines between tags. – Pointy Commented Sep 13, 2014 at 13:02
1 Answer
Reset to default 6This XPath can return either text node or element :
//*[@id="sortOrderSelect"]/child::node()
But seems that the library you're using only support XPath expressions that return element :
//*[@id="sortOrderSelect"]/*