I am testing an electron app using Spectron and webdriverIO, when I try to locate an element using xpath, it doesn't seems to work, as when I log in the console it tells me the element is undefined. The html code is shown below:
<div class="shadowdiv style-scope bmp-graphs" id="bmsgraphsdiv">
<span class="style-scope bmp-graphs"><a class="style-scope bmp-
graphs">some text</a></span>
</div>
The copied Xpath from Chrome developer tool is
//*[@id="bmsgraphsdiv"]/span/a
And when I put this into my test code below (Using Spectron, Mocha and Chai)
it('text test', function () {
var text = app.client.element('//*[@id="bmsgraphsdiv"]/span/a');
var innerText = text.innerText;
console.log("text is " + innerText);
return expect(innerText).to.eventually.equal('some text');
});
Seems like it doesn't like the attribute based Xpath that I used in the element()
function. Anyone know why is that or is there anyway else I can get the element without using the text, since the inner text is one of the things that I am text with?