minkphp / minkphp/Mink

XPathManupulator parentesis handling bug

Open
#593 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
1.6k
Forks
286
PR merge metrics
No merged PRs in 30d

Description

Consider following input:

  • prefix: descendant-or-self::*[@id = 'checkbox-with-preceding-label']
  • xpath: (//label[@for = 'checkbox-with-preceding-label'])[1]

I expect result to be descendant-or-self::*[@id = 'checkbox-with-preceding-label']/(//label[@for = 'checkbox-with-preceding-label'])[1] (both prefix and xpath combined using /).

In reality this produced this xpath: (descendant-or-self::*[@id = 'checkbox-with-preceding-label']//label[@for = 'checkbox-with-preceding-label'])[1] (the prefix is injected into parenthesis and produces xpath that doesn't match what's expected).

I'm using parentheses in xpath to specify which of found elements I want to get. It as well can be 5th element, so using find instead of findAll method isn't a viable solution.

P.S.
I'm trying to find matching label by for attribute across the document, but I start with checkbox xpath, that I can't change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the XPathManupulator implementation and reproduce the issue with the prefix and parenthesized XPath shown in the report. Compare the generated XPath with the expected slash-combined form; done means parenthesized element selection preserves the intended scope and existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.