Skip to content

is there a way to group selectors to specify precedence? #101

@dreyks

Description

@dreyks

I'm trying to generate the following xpath string (so that I get the deepest element that contains the text I need)

(//*[contains(normalize-space(string(.)), 'Text')]/@id)[position() = last()]

but

XPath.anywhere[XPath.string.n.contains('Text')].attr(:id)[XPath.position.equals(XPath.last)]

generates

//*[contains(normalize-space(string(.)), 'Text')]/@id[(position() = last())]

which is kinda logical, considering how the XPath gem works in general, but not what I want :)

I've looked through the code and looks like there's no way to add parenthesis to the on in a where expression, but maybe I'm missing something

I can't do the filtering in the ruby-land because this is only a part of my bigger XPath selector so I need it to return only one node

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions