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

Unable to use the withTag method of the PageElement class for locating a nested element by tag only #3529

Open
fecrol opened this issue Sep 9, 2024 · 2 comments

Comments

@fecrol
Copy link
Contributor

fecrol commented Sep 9, 2024

What happened?

As part of some client work, I was trying to locate an element by tag using the PageElement class within another Target instance using something akin to the below:

PageElement.withTag("div").inside(SomeOtherTarget.withName("someName"));

Rather than returning the first div within SomeOtherTarget, the first div closest to document root was being returned.

Had a look through the codebase and tracked down the issue to line 16 of the PageElement class
private static final String BY_TAG = "xpath://{0}";

There is a missing . character before the //. Meaning that rather than locating the element from the current node, the element is being located from document root.

What did you expect to happen?

Expecting the first element with provided tag to be returned from within the element in which I am trying to located it in.

Serenity BDD version

4.1.20

JDK version

17

Execution environment

OS: Windows
Browser: Chrome

How to reproduce the bug.

Try locating any element within another element by tag only using the withTag method of the PageElement class, where 1 or more elements with that tag exists outside of the node in which you are trying to locate the element in.

How can we make it happen?

Work on this myself and propose a PR (with Serenity BDD team guidance)

@wakaleo
Copy link
Member

wakaleo commented Sep 9, 2024

Well spotted - should be a simple fix

@fecrol
Copy link
Contributor Author

fecrol commented Sep 9, 2024

Hi @wakaleo, thanks. I have now raised a quick PR for this here #3530

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants