0

I have an RSS feed which should have only 1 'item' in it. I know that I can do I.see() to check that any number exists; but is it possible to check if exactly 1 exists?

I know for elements (in html) I have much more flexibility than simply I.see(). Is it possible to see xml as elements?

fpsthirty
  • 185
  • 1
  • 4
  • 15
liquidcms
  • 301
  • 1
  • 3
  • 17
  • I did not work with XML files, but maybe you can use function `I.seeNumberOfElements(locator, num)`. XPath locator works with xml too. It's used for mobile testing with Appium, for example. – Evgeny Lukoyanov Nov 26 '18 at 07:57
  • Yes, you would think it should work. But no luck so far. /rss/channel/item, //item, /item, and numerous other combinations all give "not valid xpath selector, not valid selector or expected visible elements '[]' not to be empty". – liquidcms Nov 26 '18 at 16:44

1 Answers1

0
const DOMParser = require('xmldom').DOMParser;
let parser = new DOMParser();
let elementTagName = "rss"; // set tag of your element here
let xmlXpath = "//body/pre";

I.waitForElement(xmlXpath);
let innerText = await I.grabTextFrom(xmlXpath);
let documentCustom = parser.parseFromString(innerText, "text/xml");
let documentCustomGetElement = documentCustom.getElementsByTagName(elementTagName)[0].childNodes; // your element here

You can try it for this rss-feed.

fpsthirty
  • 185
  • 1
  • 4
  • 15