Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The string 'following-sibling:://*' is not a valid XPath expression #53

Open
johnsickels opened this issue Sep 8, 2020 · 5 comments
Open
Labels
bug Something isn't working

Comments

@johnsickels
Copy link
Collaborator

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");
  });
@johnsickels johnsickels added the bug Something isn't working label Sep 8, 2020
@johnsickels
Copy link
Collaborator Author

I think it has to do with this

@johnsickels
Copy link
Collaborator Author

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

@johnsickels johnsickels mentioned this issue Oct 16, 2020
Closed
@jasonbyrne
Copy link
Collaborator

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

@johnsickels
Copy link
Collaborator Author

johnsickels commented Jun 9, 2021

In

protected _xQuery(
prefix: string,
selector: string = "*",
suffix: string = ""
) {
const path = `${prefix}${cssXPath(selector)}${suffix}`;
return this.$.$x(path);
}

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

@johnsickels
Copy link
Collaborator Author

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();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants