flagpole
flagpole copied to clipboard
The string 'following-sibling:://*' is not a valid XPath expression
Using .getNextSibling() errors in browser scenarios:
✕ Error: Evaluation failed: DOMException: Failed to execute 'evaluate' on 'Document': The string 'following-sibling:://*' is not a valid XPath expression. at __puppeteer_evaluation_script__:3:37
But succeeds in other scenarios (html):
✔ span.current-school under Next Sibling of h1 [0] has text "Gulf HS"
Flagpole version: 2.5.3
Reproduction:
import flagpole from "flagpole";
const suite = flagpole("Basic Smoke Test of Site");
suite
.scenario("Homepage Loads", "browser")
.open("https://fl.milesplit.com/athletes/pro/1038826/stats")
.next(async (context) => {
const h1 = await context.exists("h1");
const p = await h1.getNextSibling();
const currentSchool = await p.find("span.current-school");
await context.assert(currentSchool).hasText("Gulf HS");
});
I think it has to do with this
Also finding issue here
const streamIDLabel = await context.find(".prop", "streamId");
const streamIDAncestor = await streamIDLabel.getAncestor("a");
fails on error
Error: Evaluation failed: DOMException: Failed to execute 'evaluate' on 'Document': The string 'ancestor:://a' is not a valid XPath expression. at __puppeteer_evaluation_script__:3:39
Started working on this but this is gonna take me longer because xpath is kind of a pain. Gonna release the update without this fix and then try to circle back
In https://github.com/flagpolejs/flagpole/blob/1cb99e60c9650f07e855c386f8a9c0b470a3da87/src/puppeteer/browserelement.ts#L562-L569
return this.$.$x(`//${prefix}${cssXPath(selector).slice(2)}${suffix}`);
This is all the work I've done so far. This is working for .getAncestor("a") and .getNextSibling(".num"), but NOT for .getFirstChild()
For the last, I still get
child::undefined[1]
I closed the PR stale because I wanted the branch name back
Getting error
✕ TypeError: csstoxpath_1.default is not a function
when using
const listItems = await context.findAll(".upcoming .events-group li");
const firstItem = listItems[0];
context.assert("Found first li", firstItem).exists();
const secondItem = await firstItem.getNextSibling();